2 USING: kernel math namespaces make tools.test vectors sequences
3 sequences.private hashtables io prettyprint assocs
4 continuations specialized-arrays.double ;
6 [ t ] [ H{ } dup assoc-subset? ] unit-test
7 [ f ] [ H{ { 1 3 } } H{ } assoc-subset? ] unit-test
8 [ t ] [ H{ } H{ { 1 3 } } assoc-subset? ] unit-test
9 [ t ] [ H{ { 1 3 } } H{ { 1 3 } } assoc-subset? ] unit-test
10 [ f ] [ H{ { 1 3 } } H{ { 1 "hey" } } assoc-subset? ] unit-test
11 [ f ] [ H{ { 1 f } } H{ } assoc-subset? ] unit-test
12 [ t ] [ H{ { 1 f } } H{ { 1 f } } assoc-subset? ] unit-test
14 ! Test some combinators
23 } [ * 2 + , ] assoc-each
27 [ t ] [ H{ } [ 2drop f ] assoc-all? ] unit-test
28 [ t ] [ H{ { 1 1 } } [ = ] assoc-all? ] unit-test
29 [ f ] [ H{ { 1 2 } } [ = ] assoc-all? ] unit-test
30 [ t ] [ H{ { 1 1 } { 2 2 } } [ = ] assoc-all? ] unit-test
31 [ f ] [ H{ { 1 2 } { 2 2 } } [ = ] assoc-all? ] unit-test
33 [ H{ } ] [ H{ { t f } { f t } } [ 2drop f ] assoc-filter ] unit-test
34 [ H{ { 3 4 } { 4 5 } { 6 7 } } ] [
35 H{ { 1 2 } { 2 3 } { 3 4 } { 4 5 } { 6 7 } }
36 [ drop 3 >= ] assoc-filter
49 H{ } clone "cache-test" set
51 [ 4 ] [ 1 "cache-test" get [ 3 + ] cache ] unit-test
52 [ 5 ] [ 2 "cache-test" get [ 3 + ] cache ] unit-test
53 [ 4 ] [ 1 "cache-test" get [ 3 + ] cache ] unit-test
54 [ 5 ] [ 2 "cache-test" get [ 3 + ] cache ] unit-test
57 H{ { "factor" "rocks" } { 3 4 } }
59 H{ { "factor" "rocks" } { "dup" "sq" } { 3 4 } }
60 H{ { "factor" "rocks" } { 1 2 } { 2 3 } { 3 4 } }
65 H{ { 1 2 } { 2 3 } { 6 5 } }
67 H{ { 2 4 } { 6 5 } } H{ { 1 2 } { 2 3 } }
71 [ H{ { 1 2 } { 2 3 } } t ] [
72 f H{ { 1 2 } { 2 3 } } [ assoc-union ] 2keep swap assoc-union dupd =
78 H{ { 1 f } } H{ { 1 f } } assoc-intersect
81 [ { 1 3 } ] [ H{ { 2 2 } } { 1 2 3 } remove-all ] unit-test
83 [ H{ { "hi" 2 } { 3 4 } } ]
84 [ "hi" 1 H{ { 1 2 } { 3 4 } } clone [ rename-at ] keep ]
87 [ H{ { 1 2 } { 3 4 } } ]
88 [ "hi" 5 H{ { 1 2 } { 3 4 } } clone [ rename-at ] keep ]
92 H{ { 1.0 1.0 } { 2.0 2.0 } }
94 double-array{ 1.0 2.0 } [ dup ] H{ } map>assoc
102 2dup [ , f ] cache drop
111 { "fries" "onion rings" }
114 { "bangers" "fries" } H{
117 { "fries" "onion rings" }
118 { "nachos" "cheese" }
123 "a" H{ { "a" f } } at-default
127 "b" H{ { "a" f } } at-default
131 "a" H{ { "a" "x" } } at-default