From ab81a957c9524e8cc991d3ae915c9f44366ff61b Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 3 Mar 2020 08:09:52 -0800 Subject: [PATCH] logic.examples: cleanup, make hanoi tests assert output. --- .../examples/factorial/factorial-tests.factor | 1 - extra/logic/examples/fib/fib-tests.factor | 1 - extra/logic/examples/fib2/fib2-tests.factor | 1 - extra/logic/examples/hanoi/hanoi-tests.factor | 28 ++++++++--------- .../logic/examples/hanoi2/hanoi2-tests.factor | 30 +++++++++---------- extra/logic/examples/money/money-tests.factor | 1 - .../zebra-short/zebra-short-tests.factor | 1 - .../examples/zebra-short/zebra-short.factor | 2 +- extra/logic/examples/zebra/zebra-tests.factor | 1 - .../logic/examples/zebra2/zebra2-tests.factor | 1 - 10 files changed, 27 insertions(+), 40 deletions(-) diff --git a/extra/logic/examples/factorial/factorial-tests.factor b/extra/logic/examples/factorial/factorial-tests.factor index 645ae926c0..5d6208fc78 100644 --- a/extra/logic/examples/factorial/factorial-tests.factor +++ b/extra/logic/examples/factorial/factorial-tests.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2019-2020 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test logic logic.examples.factorial ; -IN: logic.examples.factorial.tests { { H{ { F 1 } } } } [ { factorial 0 F } query ] unit-test diff --git a/extra/logic/examples/fib/fib-tests.factor b/extra/logic/examples/fib/fib-tests.factor index 364ba8f114..6e9b1402af 100644 --- a/extra/logic/examples/fib/fib-tests.factor +++ b/extra/logic/examples/fib/fib-tests.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2019-2020 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test logic lists logic.examples.fib ; -IN: logic.examples.fib.tests { { H{ { L L{ 0 } } } } } [ { fibo 0 L } query ] unit-test diff --git a/extra/logic/examples/fib2/fib2-tests.factor b/extra/logic/examples/fib2/fib2-tests.factor index 8bb3bb3b00..a392acb9a0 100644 --- a/extra/logic/examples/fib2/fib2-tests.factor +++ b/extra/logic/examples/fib2/fib2-tests.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2019 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test logic logic.examples.fib2 ; -IN: logic.examples.fib2.tests { { H{ { F 6765 } } } } [ { fibo 20 F } query diff --git a/extra/logic/examples/hanoi/hanoi-tests.factor b/extra/logic/examples/hanoi/hanoi-tests.factor index c7a4178bd9..abf1923afa 100644 --- a/extra/logic/examples/hanoi/hanoi-tests.factor +++ b/extra/logic/examples/hanoi/hanoi-tests.factor @@ -1,20 +1,16 @@ ! Copyright (C) 2019-2020 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test logic logic.examples.hanoi -formatting sequences ; -IN: logic.examples.hanoi.tests +USING: io.streams.string literals logic logic.examples.hanoi +multiline tools.test ; -{ t } [ - { - "The following statements will be printed:" - "move disk from left to center" - "move disk from left to right" - "move disk from center to right" - "move disk from left to center" - "move disk from right to left" - "move disk from right to center" - "move disk from left to center" - " " - } [ "%s\n" printf ] each - { hanoi 3 } query +${ + t [=[ move disk from left to center +move disk from left to right +move disk from center to right +move disk from left to center +move disk from right to left +move disk from right to center +move disk from left to center +]=] } [ + [ { hanoi 3 } query ] with-string-writer ] unit-test diff --git a/extra/logic/examples/hanoi2/hanoi2-tests.factor b/extra/logic/examples/hanoi2/hanoi2-tests.factor index f3e5261b04..1c58577ce7 100644 --- a/extra/logic/examples/hanoi2/hanoi2-tests.factor +++ b/extra/logic/examples/hanoi2/hanoi2-tests.factor @@ -1,20 +1,18 @@ ! Copyright (C) 2019-2020 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test logic lists logic.examples.hanoi2 -formatting sequences ; -IN: logic.examples.hanoi2.tests +USING: io.streams.string multiline logic lists +logic.examples.hanoi2 sequences tools.test ; -{ t } [ - { - "The following statements will be printed:" - "move Top from Left to Center" - "move 2nd from Left to Right" - "move Top from Center to Right" - "move Base from Left to Center" - "move Top from Right to Left" - "move 2nd from Right to Center" - "move Top from Left to Center" - " " - } [ "%s\n" printf ] each - { hanoi L{ "Base" "2nd" "Top" } "Left" "Center" "Right" } query +{ + t [=[ move Top from Left to Center +move 2nd from Left to Right +move Top from Center to Right +move Base from Left to Center +move Top from Right to Left +move 2nd from Right to Center +move Top from Left to Center +]=] } [ + [ + { hanoi L{ "Base" "2nd" "Top" } "Left" "Center" "Right" } query + ] with-string-writer ] unit-test diff --git a/extra/logic/examples/money/money-tests.factor b/extra/logic/examples/money/money-tests.factor index 47e9f9eb50..318c50cf16 100644 --- a/extra/logic/examples/money/money-tests.factor +++ b/extra/logic/examples/money/money-tests.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2019-2020 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test logic lists logic.examples.money ; -IN: logic.examples.money.tests { { diff --git a/extra/logic/examples/zebra-short/zebra-short-tests.factor b/extra/logic/examples/zebra-short/zebra-short-tests.factor index 315fcb6f32..73865c34a7 100644 --- a/extra/logic/examples/zebra-short/zebra-short-tests.factor +++ b/extra/logic/examples/zebra-short/zebra-short-tests.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2019 Your name. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test logic logic.examples.zebra-short ; -IN: logic.examples.zebra-short.tests { { H{ { X japanese } } H{ { X japanese } } } diff --git a/extra/logic/examples/zebra-short/zebra-short.factor b/extra/logic/examples/zebra-short/zebra-short.factor index 576e37ecca..ba9d9524ff 100644 --- a/extra/logic/examples/zebra-short/zebra-short.factor +++ b/extra/logic/examples/zebra-short/zebra-short.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2019 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. -USING: logic arrays ; +USING: logic lists ; IN: logic.examples.zebra-short ! Do the same as this Prolog program diff --git a/extra/logic/examples/zebra/zebra-tests.factor b/extra/logic/examples/zebra/zebra-tests.factor index 366c97c1d8..7d0e0a3adf 100644 --- a/extra/logic/examples/zebra/zebra-tests.factor +++ b/extra/logic/examples/zebra/zebra-tests.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2019-2020 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test logic lists logic.examples.zebra ; -IN: logic.examples.zebra.tests { { diff --git a/extra/logic/examples/zebra2/zebra2-tests.factor b/extra/logic/examples/zebra2/zebra2-tests.factor index 6669e67154..1bdb3a1cf4 100644 --- a/extra/logic/examples/zebra2/zebra2-tests.factor +++ b/extra/logic/examples/zebra2/zebra2-tests.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2019-2020 KUSUMOTO Norio. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test logic lists logic.examples.zebra2 ; -IN: logic.examples.zebra2.tests { {