]> gitweb.factorcode.org Git - factor.git/commitdiff
logic.examples: cleanup, make hanoi tests assert output.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 3 Mar 2020 16:09:52 +0000 (08:09 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 3 Mar 2020 16:09:52 +0000 (08:09 -0800)
extra/logic/examples/factorial/factorial-tests.factor
extra/logic/examples/fib/fib-tests.factor
extra/logic/examples/fib2/fib2-tests.factor
extra/logic/examples/hanoi/hanoi-tests.factor
extra/logic/examples/hanoi2/hanoi2-tests.factor
extra/logic/examples/money/money-tests.factor
extra/logic/examples/zebra-short/zebra-short-tests.factor
extra/logic/examples/zebra-short/zebra-short.factor
extra/logic/examples/zebra/zebra-tests.factor
extra/logic/examples/zebra2/zebra2-tests.factor

index 645ae926c0257faa018c3ac70ff68e8e5b6662e3..5d6208fc781df51043895b772dad96a66db3d4bd 100644 (file)
@@ -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
 
index 364ba8f114dcd747764f471c20c71e09f2f7bd87..6e9b1402afb1df7a66ce7dd16024097bdf21d89e 100644 (file)
@@ -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
 
index 8bb3bb3b0053c6f13b47067886574f54f75400c4..a392acb9a0d417df737bcce9c783bb093d789864 100644 (file)
@@ -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
index c7a4178bd9a4b6e7c4cea0b4962055d65c1d4c48..abf1923afaa6f9efe455af1ed15f8f1ee8c20069 100644 (file)
@@ -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
index f3e5261b04a7783c57f698f5c475281020b2f468..1c58577ce76fdbbe584210e3f1506e1ac6b87012 100644 (file)
@@ -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
index 47e9f9eb50a09b4781f9ab8cbe44a5da10169e44..318c50cf164406e05f5ab0fbfb295ec8aa524fd7 100644 (file)
@@ -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
 
 {
     {
index 315fcb6f32be0fa3144a0dea9e96b7242331c52e..73865c34a73921a865a778d96dd9a0ad9c61a273 100644 (file)
@@ -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 } } }
index 576e37eccaa03d94abea4273e57968c4a85202ed..ba9d9524ff2208b1ba09ed12a747640ca697defd 100644 (file)
@@ -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
index 366c97c1d8e8291129d690e8b73da5b67ab1a291..7d0e0a3adfbb82bc05dca5dcbcbfb6db04f7c9fb 100644 (file)
@@ -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
 
 {
     {
index 6669e6715428390c24b41fbfe34feaab873a5467..1bdb3a1cf4621068fcf654c91c1e1695a26b516d 100644 (file)
@@ -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
 
 {
     {