]> gitweb.factorcode.org Git - factor.git/blob - basis/vlists/vlists-tests.factor
Use factor.com to get stdout
[factor.git] / basis / vlists / vlists-tests.factor
1 USING: vlists kernel persistent.sequences arrays tools.test
2 namespaces accessors sequences assocs ;
3
4 { { "hi" "there" } }
5 [ VL{ } "hi" swap ppush "there" swap ppush >array ] unit-test
6
7 { VL{ "hi" "there" "foo" } VL{ "hi" "there" "bar" } t }
8 [
9     VL{ } "hi" swap ppush "there" swap ppush "v" set
10     "foo" "v" get ppush
11     "bar" "v" get ppush
12     dup "baz" over ppush [ vector>> ] bi@ eq?
13 ] unit-test
14
15 { "foo" VL{ "hi" "there" } t }
16 [
17     VL{ "hi" "there" "foo" } dup "v" set
18     [ last ] [ ppop ] bi
19     dup "v" get [ vector>> ] bi@ eq?
20 ] unit-test
21
22 [ VL{ } 3 suffix! ] must-fail
23
24 [ 4 VL{ "hi" } set-first ] must-fail
25
26 { 5 t } [
27     "rice" VA{ { "rice" 5 } { "beans" 10 } } at*
28 ] unit-test
29
30 { 6 t } [
31     "rice" VA{ { "rice" 5 } { "beans" 10 } { "rice" 6 } } at*
32 ] unit-test
33
34 { 3 } [
35     VA{ { "rice" 5 } { "beans" 10 } { "rice" 6 } } assoc-size
36 ] unit-test
37
38 { f f } [
39     "meat" VA{ { "rice" 5 } { "beans" 10 } { "rice" 6 } } at*
40 ] unit-test