Merge branch 'master' of git://factorcode.org/git/factor
[factor/jcg.git] / basis / sequences / deep / deep-tests.factor
blob2d3260f4279154a8cddb834b99efd2076a9bcad0
1 USING: sequences.deep kernel tools.test strings math arrays
2 namespaces make sequences ;
3 IN: sequences.deep.tests
5 [ [ "hello" 3 4 swap ] ] [ [ { "hello" V{ 3 4 } } swap ] flatten ] unit-test
7 [ "foo" t ] [ { { "foo" } "bar" } [ string? ] (deep-find) ] unit-test
9 [ f f ] [ { { "foo" } "bar" } [ number? ] (deep-find) ] unit-test
11 [ { { "foo" } "bar" } t ] [ { { "foo" } "bar" } [ array? ] (deep-find) ] unit-test
13 : change-something ( seq -- newseq )
14     dup array? [ "hi" suffix ] [ "hello" append ] if ;
16 [ { { "heyhello" "hihello" } "hihello" } ]
17 [ "hey" 1array 1array [ change-something ] deep-map ] unit-test
19 [ { { "heyhello" "hihello" } } ]
20 [ "hey" 1array 1array [ [ change-something ] deep-change-each ] keep ] unit-test
22 [ t ] [ "foo" [ string? ] deep-contains?  ] unit-test
24 [ "foo" ] [ "foo" [ string? ] deep-find ] unit-test
26 [ { { 1 2 } 1 2 } ] [ [ { 1 2 } [ , ] deep-each ] { } make ] unit-test
28 [ t ]
29 [ { { 1 2 3 } 4 } { { { 1 { { 1 2 3 } 4 } } } 2 } deep-member? ] unit-test
31 [ t ]
32 [ { { 1 2 3 } 4 } { { { 1 2 3 } 4 } 2 } deep-member? ] unit-test
34 [ f ]
35 [ { 1 2 3 4 } { 1 2 3 { 4 } } deep-subseq? ] unit-test
37 [ t ]
38 [ { 1 2 3 4 } { 1 2 3 4 } deep-subseq? ] unit-test
40 [ t ]
41 [ { 1 2 3 4 } { { 1 2 3 4 } } deep-subseq? ] unit-test