]> gitweb.factorcode.org Git - factor.git/blob - basis/sequences/deep/deep-tests.factor
Merge branch 'master' of http://factorcode.org/git/factor
[factor.git] / basis / sequences / deep / deep-tests.factor
1 USING: sequences.deep kernel tools.test strings math arrays
2 namespaces make sequences ;
3 IN: sequences.deep.tests
4
5 [ [ "hello" 3 4 swap ] ] [ [ { "hello" V{ 3 4 } } swap ] flatten ] unit-test
6
7 [ "foo" t ] [ { { "foo" } "bar" } [ string? ] (deep-find) ] unit-test
8
9 [ f f ] [ { { "foo" } "bar" } [ number? ] (deep-find) ] unit-test
10
11 [ { { "foo" } "bar" } t ] [ { { "foo" } "bar" } [ array? ] (deep-find) ] unit-test
12
13 : change-something ( seq -- newseq )
14     dup array? [ "hi" suffix ] [ "hello" append ] if ;
15
16 [ { { "heyhello" "hihello" } "hihello" } ]
17 [ "hey" 1array 1array [ change-something ] deep-map ] unit-test
18
19 [ { { "heyhello" "hihello" } } ]
20 [ "hey" 1array 1array [ change-something ] deep-map! ] unit-test
21
22 [ t ] [ "foo" [ string? ] deep-any?  ] unit-test
23
24 [ "foo" ] [ "foo" [ string? ] deep-find ] unit-test
25
26 [ { { 1 2 } 1 2 } ] [ [ { 1 2 } [ , ] deep-each ] { } make ] unit-test
27
28 [ t ]
29 [ { { 1 2 3 } 4 } { { { 1 { { 1 2 3 } 4 } } } 2 } deep-member? ] unit-test
30
31 [ t ]
32 [ { { 1 2 3 } 4 } { { { 1 2 3 } 4 } 2 } deep-member? ] unit-test
33
34 [ f ]
35 [ { 1 2 3 4 } { 1 2 3 { 4 } } deep-subseq? ] unit-test
36
37 [ t ]
38 [ { 1 2 3 4 } { 1 2 3 4 } deep-subseq? ] unit-test
39
40 [ t ]
41 [ { 1 2 3 4 } { { 1 2 3 4 } } deep-subseq? ] unit-test