1 USING: accessors arrays classes continuations kernel math
2 namespaces random sequences tools.test vectors ;
4 { } [ 10 [ [ -1000000 <vector> ] ignore-errors ] times ] unit-test
6 { 3 } [ [ t f t ] length ] unit-test
7 { 3 } [ V{ t f t } length ] unit-test
9 [ -3 V{ } nth ] must-fail
10 [ 3 V{ } nth ] must-fail
11 [ 3 54.3 nth ] must-fail
13 [ "hey" [ 1 2 ] set-length ] must-fail
14 [ "hey" V{ 1 2 } set-length ] must-fail
16 { 3 } [ 3 0 <vector> [ set-length ] keep length ] unit-test
18 "yo" 4 1 <vector> [ set-nth ] keep 4 swap nth
21 [ 1 V{ } nth ] must-fail
22 [ -1 V{ } set-length ] must-fail
23 { V{ } } [ [ ] >vector ] unit-test
24 { V{ 1 2 } } [ [ 1 2 ] >vector ] unit-test
27 100 [ 100 random ] V{ } replicate-as
31 { f } [ V{ } V{ 1 2 3 } = ] unit-test
32 { f } [ V{ 1 2 } V{ 1 2 3 } = ] unit-test
33 { f } [ [ 1 2 ] V{ 1 2 3 } = ] unit-test
34 { f } [ V{ 1 2 } [ 1 2 3 ] = ] unit-test
39 >vector [ dup * ] map >array
42 { t } [ V{ } hashcode V{ } hashcode = ] unit-test
43 { t } [ V{ 1 2 3 } hashcode V{ 1 2 3 } hashcode = ] unit-test
44 { t } [ V{ 1 V{ 2 } 3 } hashcode V{ 1 V{ 2 } 3 } hashcode = ] unit-test
45 { t } [ V{ } hashcode V{ } hashcode = ] unit-test
47 { V{ 1 2 3 } V{ 1 2 3 4 5 6 } }
48 [ V{ 1 2 3 } dup V{ 4 5 6 } append ] unit-test
50 { V{ 1 2 3 4 } } [ [ V{ 1 } [ 2 ] V{ 3 4 } ] concat ] unit-test
52 { V{ } } [ V{ } 0 tail ] unit-test
53 { V{ } } [ V{ 1 2 } 2 tail ] unit-test
54 { V{ 3 4 } } [ V{ 1 2 3 4 } 2 tail ] unit-test
56 { V{ 3 } } [ V{ 1 2 3 } 1 tail* ] unit-test
58 0 <vector> "funny-stack" set
60 { } [ V{ 1 5 } "funny-stack" get push ] unit-test
61 { } [ V{ 2 3 } "funny-stack" get push ] unit-test
62 { V{ 2 3 } } [ "funny-stack" get pop ] unit-test
63 { V{ 1 5 } } [ "funny-stack" get last ] unit-test
64 { V{ 1 5 } } [ "funny-stack" get pop ] unit-test
65 [ "funny-stack" get pop ] must-fail
66 [ "funny-stack" get pop ] must-fail
67 { } [ "funky" "funny-stack" get push ] unit-test
68 { "funky" } [ "funny-stack" get pop ] unit-test
71 V{ 1 2 3 4 } dup underlying>> length
72 [ clone underlying>> length ] dip
77 V{ 1 2 3 4 } dup clone
78 [ underlying>> ] bi@ eq?
87 { f } [ 5 V{ } index ] unit-test
88 { 4 } [ 5 V{ 1 2 3 4 5 } index ] unit-test
91 100 <iota> >array dup >vector <reversed> >array [ reverse ] dip =
94 { fixnum } [ 1 >bignum V{ } new-sequence length class-of ] unit-test
96 { fixnum } [ 1 >bignum <iota> [ ] V{ } map-as length class-of ] unit-test
98 { V{ "lulz" } } [ "lulz" 1vector ] unit-test