]> gitweb.factorcode.org Git - factor.git/commitdiff
generalizations: dos2unix
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 20 May 2015 22:02:04 +0000 (15:02 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 20 May 2015 22:02:04 +0000 (15:02 -0700)
basis/generalizations/generalizations-tests.factor

index 626111fffcca03cd77a73a8cf567e31fc7c86fd2..68ae642f45d54119c2473a9a170b277c8fb7cf5d 100644 (file)
-USING: tools.test generalizations kernel math arrays sequences\r
-ascii fry math.parser io io.streams.string ;\r
-IN: generalizations.tests\r
-\r
-{ 1 2 3 4 1 } [ 1 2 3 4 4 npick ] unit-test\r
-{ 1 2 3 4 2 } [ 1 2 3 4 3 npick ] unit-test\r
-{ 1 2 3 4 3 } [ 1 2 3 4 2 npick ] unit-test\r
-{ 1 2 3 4 4 } [ 1 2 3 4 1 npick ] unit-test\r
-[ 1 2 3 4 0 npick ] [ nonpositive-npick? ] must-fail-with\r
-[ 1 2 3 4 -11 npick ] [ nonpositive-npick? ] must-fail-with\r
-\r
-[ 1 1 ndup ] must-infer\r
-{ 1 1 } [ 1 1 ndup ] unit-test\r
-{ 1 2 1 2 } [ 1 2 2 ndup ] unit-test\r
-{ 1 2 3 1 2 3 } [ 1 2 3 3 ndup ] unit-test\r
-{ 1 2 3 4 1 2 3 4 } [ 1 2 3 4 4 ndup ] unit-test\r
-[ 1 2 2 nrot ] must-infer\r
-{ 2 1 } [ 1 2 2 nrot ] unit-test\r
-{ 2 3 1 } [ 1 2 3 3 nrot ] unit-test\r
-{ 2 3 4 1 } [ 1 2 3 4 4 nrot ] unit-test\r
-[ 1 2 2 -nrot ] must-infer\r
-{ 2 1 } [ 1 2 2 -nrot ] unit-test\r
-{ 3 1 2 } [ 1 2 3 3 -nrot ] unit-test\r
-{ 4 1 2 3 } [ 1 2 3 4 4 -nrot ] unit-test\r
-[ 1 2 3 4 3 nnip ] must-infer\r
-{ 4 } [ 1 2 3 4 3 nnip ] unit-test\r
-[ 1 2 3 4 4 ndrop ] must-infer\r
-{ 0 } [ 0 1 2 3 4 4 ndrop ] unit-test\r
-[ [ 1 ] 5 ndip ] must-infer\r
-{ 1 2 3 4 } [ 2 3 4 [ 1 ] 3 ndip ] unit-test\r
-\r
-[ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer\r
-[ 1 2 3 4 5 2 '[ drop drop drop drop drop _ ] 5 nkeep ] must-infer\r
-{ 2 1 2 3 4 5 } [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] unit-test\r
-{ 2 1 2 3 4 5 } [ 1 2 3 4 5 2 '[ drop drop drop drop drop _ ] 5 nkeep ] unit-test\r
-{ [ 1 2 3 + ] } [ 1 2 3 [ + ] 3 ncurry ] unit-test\r
-\r
-{ "HELLO" } [ "hello" [ >upper ] 1 napply ] unit-test\r
-{ { 1 2 } { 2 4 } { 3 8 } { 4 16 } { 5 32 } } [ 1 2 3 4 5 [ dup 2^ 2array ] 5 napply ] unit-test\r
-[ [ dup 2^ 2array ] 5 napply ] must-infer\r
-\r
-{ { "xyc" "xyd" } } [ "x" "y" { "c" "d" } [ 3append ] 2 nwith map ] unit-test\r
-\r
-{ 4 5 1 2 3 } [ 1 2 3 4 5 2 3 mnswap ] unit-test\r
-\r
-{ 1 2 3 4 5 6 } [ 1 2 3 4 5 6 2 4 mnswap 4 2 mnswap ] unit-test\r
-\r
-{ 17 } [ 3 1 3 3 7 5 nsum ] unit-test\r
-{ 4 1 } [ 4 nsum ] must-infer-as\r
-\r
-[ "e1" "o1" "o2" "e2" "o1" "o2" ] [ "e1" "e2" "o1" "o2" 2 nweave ] unit-test\r
-{ 3 5 } [ 2 nweave ] must-infer-as\r
-\r
-{ { 0 1 2 } { 3 5 4 } { 7 8 6 } }\r
-[ 9 [ ] each-integer { [ 3array ] [ swap 3array ] [ rot 3array ] } 3 nspread ] unit-test\r
-\r
-{ 1 2 3 4 1 2 3 } [ 1 2 3 4 3 nover ] unit-test\r
-\r
-{ [ 1 2 3 ] [ 1 2 3 ] }\r
-[ 1 2 3 [ ] [ ] 3 nbi-curry ] unit-test\r
-\r
-{ 15 3 } [ 1 2 3 4 5 [ + + + + ] [ - - - - ] 5 nbi ] unit-test\r
-\r
-: nover-test ( -- a b c d e f g )\r
-   1 2 3 4 3 nover ;\r
-\r
-{ 1 2 3 4 1 2 3 } [ nover-test ] unit-test\r
-\r
-[ '[ number>string _ append ] 4 napply ] must-infer\r
-\r
-{ 6 8 10 12 } [\r
-    1 2 3 4\r
-    5 6 7 8 [ + ] 4 apply-curry 4 spread*\r
-] unit-test\r
-\r
-{ 6 } [ 5 [ 1 + ] 1 spread* ] unit-test\r
-{ 6 } [ 5 [ 1 + ] 1 cleave* ] unit-test\r
-{ 6 } [ 5 [ 1 + ] 1 napply  ] unit-test\r
-\r
-{ 6 } [ 6 0 spread* ] unit-test\r
-{ 6 } [ 6 0 cleave* ] unit-test\r
-{ 6 } [ 6 [ 1 + ] 0 napply ] unit-test\r
-\r
-{ 6 7 8 9 } [\r
-    1\r
-    5 6 7 8 [ + ] 4 apply-curry 4 cleave*\r
-] unit-test\r
-\r
-{ 8 3 8 3/2 } [\r
-    6 5 4 3\r
-    2 [ + ] [ - ] [ * ] [ / ] 4 cleave-curry 4 spread*\r
-] unit-test\r
-\r
-{ 8 4 0 -3 } [\r
-    6 5 4  3\r
-    2 1 0 -1 [ + ] [ - ] [ * ] [ / ] 4 spread-curry 4 spread*\r
-] unit-test\r
-\r
-{ { 1 2 } { 3 4 } { 5 6 } }\r
-[ 1 2 3 4 5 6 [ 2array ] 2 3 mnapply ] unit-test\r
-\r
-{ { 1 2 3 } { 4 5 6 } }\r
-[ 1 2 3 4 5 6 [ 3array ] 3 2 mnapply ] unit-test\r
-\r
-{ { 1 2 3 } { 4 5 6 } }\r
-[ 1 2 3 4 5 6 [ 3array ] [ 3array ] 3 2 nspread* ] unit-test\r
-\r
-{ }\r
-[ [ 2array ] 2 0 mnapply ] unit-test\r
-\r
-{ }\r
-[ 2 0 nspread* ] unit-test\r
+USING: tools.test generalizations kernel math arrays sequences
+ascii fry math.parser io io.streams.string ;
+IN: generalizations.tests
+
+{ 1 2 3 4 1 } [ 1 2 3 4 4 npick ] unit-test
+{ 1 2 3 4 2 } [ 1 2 3 4 3 npick ] unit-test
+{ 1 2 3 4 3 } [ 1 2 3 4 2 npick ] unit-test
+{ 1 2 3 4 4 } [ 1 2 3 4 1 npick ] unit-test
+[ 1 2 3 4 0 npick ] [ nonpositive-npick? ] must-fail-with
+[ 1 2 3 4 -11 npick ] [ nonpositive-npick? ] must-fail-with
+
+[ 1 1 ndup ] must-infer
+{ 1 1 } [ 1 1 ndup ] unit-test
+{ 1 2 1 2 } [ 1 2 2 ndup ] unit-test
+{ 1 2 3 1 2 3 } [ 1 2 3 3 ndup ] unit-test
+{ 1 2 3 4 1 2 3 4 } [ 1 2 3 4 4 ndup ] unit-test
+[ 1 2 2 nrot ] must-infer
+{ 2 1 } [ 1 2 2 nrot ] unit-test
+{ 2 3 1 } [ 1 2 3 3 nrot ] unit-test
+{ 2 3 4 1 } [ 1 2 3 4 4 nrot ] unit-test
+[ 1 2 2 -nrot ] must-infer
+{ 2 1 } [ 1 2 2 -nrot ] unit-test
+{ 3 1 2 } [ 1 2 3 3 -nrot ] unit-test
+{ 4 1 2 3 } [ 1 2 3 4 4 -nrot ] unit-test
+[ 1 2 3 4 3 nnip ] must-infer
+{ 4 } [ 1 2 3 4 3 nnip ] unit-test
+[ 1 2 3 4 4 ndrop ] must-infer
+{ 0 } [ 0 1 2 3 4 4 ndrop ] unit-test
+[ [ 1 ] 5 ndip ] must-infer
+{ 1 2 3 4 } [ 2 3 4 [ 1 ] 3 ndip ] unit-test
+
+[ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer
+[ 1 2 3 4 5 2 '[ drop drop drop drop drop _ ] 5 nkeep ] must-infer
+{ 2 1 2 3 4 5 } [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] unit-test
+{ 2 1 2 3 4 5 } [ 1 2 3 4 5 2 '[ drop drop drop drop drop _ ] 5 nkeep ] unit-test
+{ [ 1 2 3 + ] } [ 1 2 3 [ + ] 3 ncurry ] unit-test
+
+{ "HELLO" } [ "hello" [ >upper ] 1 napply ] unit-test
+{ { 1 2 } { 2 4 } { 3 8 } { 4 16 } { 5 32 } } [ 1 2 3 4 5 [ dup 2^ 2array ] 5 napply ] unit-test
+[ [ dup 2^ 2array ] 5 napply ] must-infer
+
+{ { "xyc" "xyd" } } [ "x" "y" { "c" "d" } [ 3append ] 2 nwith map ] unit-test
+
+{ 4 5 1 2 3 } [ 1 2 3 4 5 2 3 mnswap ] unit-test
+
+{ 1 2 3 4 5 6 } [ 1 2 3 4 5 6 2 4 mnswap 4 2 mnswap ] unit-test
+
+{ 17 } [ 3 1 3 3 7 5 nsum ] unit-test
+{ 4 1 } [ 4 nsum ] must-infer-as
+
+[ "e1" "o1" "o2" "e2" "o1" "o2" ] [ "e1" "e2" "o1" "o2" 2 nweave ] unit-test
+{ 3 5 } [ 2 nweave ] must-infer-as
+
+{ { 0 1 2 } { 3 5 4 } { 7 8 6 } }
+[ 9 [ ] each-integer { [ 3array ] [ swap 3array ] [ rot 3array ] } 3 nspread ] unit-test
+
+{ 1 2 3 4 1 2 3 } [ 1 2 3 4 3 nover ] unit-test
+
+{ [ 1 2 3 ] [ 1 2 3 ] }
+[ 1 2 3 [ ] [ ] 3 nbi-curry ] unit-test
+
+{ 15 3 } [ 1 2 3 4 5 [ + + + + ] [ - - - - ] 5 nbi ] unit-test
+
+: nover-test ( -- a b c d e f g )
+   1 2 3 4 3 nover ;
+
+{ 1 2 3 4 1 2 3 } [ nover-test ] unit-test
+
+[ '[ number>string _ append ] 4 napply ] must-infer
+
+{ 6 8 10 12 } [
+    1 2 3 4
+    5 6 7 8 [ + ] 4 apply-curry 4 spread*
+] unit-test
+
+{ 6 } [ 5 [ 1 + ] 1 spread* ] unit-test
+{ 6 } [ 5 [ 1 + ] 1 cleave* ] unit-test
+{ 6 } [ 5 [ 1 + ] 1 napply  ] unit-test
+
+{ 6 } [ 6 0 spread* ] unit-test
+{ 6 } [ 6 0 cleave* ] unit-test
+{ 6 } [ 6 [ 1 + ] 0 napply ] unit-test
+
+{ 6 7 8 9 } [
+    1
+    5 6 7 8 [ + ] 4 apply-curry 4 cleave*
+] unit-test
+
+{ 8 3 8 3/2 } [
+    6 5 4 3
+    2 [ + ] [ - ] [ * ] [ / ] 4 cleave-curry 4 spread*
+] unit-test
+
+{ 8 4 0 -3 } [
+    6 5 4  3
+    2 1 0 -1 [ + ] [ - ] [ * ] [ / ] 4 spread-curry 4 spread*
+] unit-test
+
+{ { 1 2 } { 3 4 } { 5 6 } }
+[ 1 2 3 4 5 6 [ 2array ] 2 3 mnapply ] unit-test
+
+{ { 1 2 3 } { 4 5 6 } }
+[ 1 2 3 4 5 6 [ 3array ] 3 2 mnapply ] unit-test
+
+{ { 1 2 3 } { 4 5 6 } }
+[ 1 2 3 4 5 6 [ 3array ] [ 3array ] 3 2 nspread* ] unit-test
+
+{ }
+[ [ 2array ] 2 0 mnapply ] unit-test
+
+{ }
+[ 2 0 nspread* ] unit-test