Merge branch 'master' of git://factorcode.org/git/factor
[factor/jcg.git] / basis / vlists / vlists-tests.factor
blob3546051364ec5b4450dd8208ce5ef82924b168bf
1 USING: vlists kernel persistent.sequences arrays tools.test
2 namespaces accessors sequences assocs ;
3 IN: vlists.tests
5 [ { "hi" "there" } ]
6 [ VL{ } "hi" swap ppush "there" swap ppush >array ] unit-test
8 [ VL{ "hi" "there" "foo" } VL{ "hi" "there" "bar" } t ]
10     VL{ } "hi" swap ppush "there" swap ppush "v" set
11     "foo" "v" get ppush
12     "bar" "v" get ppush
13     dup "baz" over ppush [ vector>> ] bi@ eq?
14 ] unit-test
16 [ "foo" VL{ "hi" "there" } t ]
18     VL{ "hi" "there" "foo" } dup "v" set
19     [ peek ] [ ppop ] bi
20     dup "v" get [ vector>> ] bi@ eq?
21 ] unit-test
23 [ VL{ } 3 over push ] must-fail
25 [ 4 VL{ "hi" } set-first ] must-fail
27 [ 5 t ] [
28     "rice" VA{ { "rice" 5 } { "beans" 10 } } at*
29 ] unit-test
31 [ 6 t ] [
32     "rice" VA{ { "rice" 5 } { "beans" 10 } { "rice" 6 } } at*
33 ] unit-test
35 [ 3 ] [
36     VA{ { "rice" 5 } { "beans" 10 } { "rice" 6 } } assoc-size
37 ] unit-test
39 [ f f ] [
40     "meat" VA{ { "rice" 5 } { "beans" 10 } { "rice" 6 } } at*
41 ] unit-test