]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/combinators/smart/smart-tests.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / basis / combinators / smart / smart-tests.factor
index 4be445e465a47cdce7b38d6968cd18443605e26b..399b4dc36fe35feaf226288c2944ea555094265c 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test combinators.smart math kernel ;
+USING: tools.test combinators.smart math kernel accessors ;
 IN: combinators.smart.tests
 
 : test-bi ( -- 9 11 )
-    10 [ 1- ] [ 1+ ] bi ;
+    10 [ 1 - ] [ 1 + ] bi ;
 
 [ [ test-bi ] output>array ] must-infer
 [ { 9 11 } ] [ [ test-bi ] output>array ] unit-test
@@ -12,10 +12,38 @@ IN: combinators.smart.tests
 [ { 9 11 } [ + ] input<sequence ] must-infer
 [ 20 ] [ { 9 11 } [ + ] input<sequence ] unit-test
 
+[ 6 ] [ [ 1 2 3 ] [ + ] reduce-outputs ] unit-test
 
+[ [ 1 2 3 ] [ + ] reduce-outputs ] must-infer
 
-[ 6 ] [ [ 1 2 3 ] [ + ] reduce-output ] unit-test
+[ 6 ] [ [ 1 2 3 ] sum-outputs ] unit-test
 
-[ [ 1 2 3 ] [ + ] reduce-output ] must-infer
+[ "ab" ]
+[
+    [ "a" "b" ] "" append-outputs-as
+] unit-test
 
-[ 6 ] [ [ 1 2 3 ] sum-outputs ] unit-test
+[ "" ]
+[
+    [ ] "" append-outputs-as
+] unit-test
+
+[ { } ]
+[
+    [ ] append-outputs
+] unit-test
+
+[ B{ 1 2 3 } ]
+[
+    [ { 1 } { 2 } { 3 } ] B{ } append-outputs-as
+] unit-test
+
+! Test nesting
+: nested-smart-combo-test ( -- array )
+    [ [ 1 2 ] output>array [ 3 4 ] output>array ] output>array ;
+
+\ nested-smart-combo-test def>> must-infer
+
+[ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test
+
+[ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test