1 USING: tools.test generalizations kernel math arrays sequences ascii ;
\r
2 IN: generalizations.tests
\r
4 { 1 2 3 4 1 } [ 1 2 3 4 4 npick ] unit-test
\r
5 { 1 2 3 4 2 } [ 1 2 3 4 3 npick ] unit-test
\r
6 { 1 2 3 4 3 } [ 1 2 3 4 2 npick ] unit-test
\r
7 { 1 2 3 4 4 } [ 1 2 3 4 1 npick ] unit-test
\r
9 [ 1 1 ndup ] must-infer
\r
10 { 1 1 } [ 1 1 ndup ] unit-test
\r
11 { 1 2 1 2 } [ 1 2 2 ndup ] unit-test
\r
12 { 1 2 3 1 2 3 } [ 1 2 3 3 ndup ] unit-test
\r
13 { 1 2 3 4 1 2 3 4 } [ 1 2 3 4 4 ndup ] unit-test
\r
14 [ 1 2 2 nrot ] must-infer
\r
15 { 2 1 } [ 1 2 2 nrot ] unit-test
\r
16 { 2 3 1 } [ 1 2 3 3 nrot ] unit-test
\r
17 { 2 3 4 1 } [ 1 2 3 4 4 nrot ] unit-test
\r
18 [ 1 2 2 -nrot ] must-infer
\r
19 { 2 1 } [ 1 2 2 -nrot ] unit-test
\r
20 { 3 1 2 } [ 1 2 3 3 -nrot ] unit-test
\r
21 { 4 1 2 3 } [ 1 2 3 4 4 -nrot ] unit-test
\r
22 [ 1 2 3 4 3 nnip ] must-infer
\r
23 { 4 } [ 1 2 3 4 3 nnip ] unit-test
\r
24 [ 1 2 3 4 4 ndrop ] must-infer
\r
25 { 0 } [ 0 1 2 3 4 4 ndrop ] unit-test
\r
26 [ [ 1 ] 5 ndip ] must-infer
\r
27 [ 1 2 3 4 ] [ 2 3 4 [ 1 ] 3 ndip ] unit-test
\r
29 [ [ 99 ] 1 2 3 4 5 5 nslip ] must-infer
\r
30 { 99 1 2 3 4 5 } [ [ 99 ] 1 2 3 4 5 5 nslip ] unit-test
\r
31 [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer
\r
32 { 2 1 2 3 4 5 } [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] unit-test
\r
33 [ [ 1 2 3 + ] ] [ 1 2 3 [ + ] 3 ncurry ] unit-test
\r
35 [ "HELLO" ] [ "hello" [ >upper ] 1 napply ] unit-test
\r
36 [ { 1 2 } { 2 4 } { 3 8 } { 4 16 } { 5 32 } ] [ 1 2 3 4 5 [ dup 2^ 2array ] 5 napply ] unit-test
\r
37 [ [ dup 2^ 2array ] 5 napply ] must-infer
\r
39 [ { "xyc" "xyd" } ] [ "x" "y" { "c" "d" } [ 3append ] 2 nwith map ] unit-test
\r
41 [ 1 2 3 4 ] [ { 1 2 3 4 } 4 firstn ] unit-test
\r
42 [ ] [ { } 0 firstn ] unit-test
\r
43 [ "a" ] [ { "a" } 1 firstn ] unit-test
\r
45 [ [ 1 2 ] ] [ 1 2 2 [ ] nsequence ] unit-test
\r
47 [ 4 5 1 2 3 ] [ 1 2 3 4 5 2 3 mnswap ] unit-test
\r
49 [ 1 2 3 4 5 6 ] [ 1 2 3 4 5 6 2 4 mnswap 4 2 mnswap ] unit-test
\r
51 [ { 1 2 3 4 } ] [ { 1 } { 2 } { 3 } { 4 } 4 nappend ] unit-test
\r
52 [ V{ 1 2 3 4 } ] [ { 1 } { 2 } { 3 } { 4 } 4 V{ } nappend-as ] unit-test
\r
54 [ 4 nappend ] must-infer
\r
55 [ 4 { } nappend-as ] must-infer
\r