1 IN: persistent-vectors.tests
2 USING: accessors tools.test persistent.vectors
3 persistent.sequences sequences kernel arrays random namespaces
4 vectors math math.order ;
10 [ 0 ] [ PV{ } length ] unit-test
12 [ 1 ] [ 3 PV{ } ppush length ] unit-test
14 [ 3 ] [ 3 PV{ } ppush first ] unit-test
17 PV{ } { 3 1 3 3 7 } [ swap ppush ] each
21 PV{ } { 3 1 3 3 7 } [ swap ppush ] each >array
24 { 100 1060 2000 10000 100000 1000000 } [
25 [ t ] swap [ dup >persistent-vector sequence= ] curry unit-test
28 [ ] [ 10000 [ 16 random-bits ] PV{ } replicate-as "1" set ] unit-test
29 [ ] [ "1" get >vector "2" set ] unit-test
34 16 random-bits 10000 random
35 [ "1" [ new-nth ] change ]
36 [ "2" [ new-nth ] change ] 2bi
37 "1" get "2" get sequence=
41 [ PV{ } ppop ] [ empty-error? ] must-fail-with
43 [ t ] [ PV{ 3 } ppop empty? ] unit-test
45 [ PV{ 3 7 } ] [ PV{ 3 7 6 } ppop ] unit-test
47 [ PV{ 3 7 6 5 } ] [ 5 PV{ 3 7 6 } ppush ] unit-test
49 [ ] [ PV{ } "1" set ] unit-test
50 [ ] [ V{ } clone "2" set ] unit-test
52 : push/pop-test ( vec -- vec' ) 3 swap ppush 3 swap ppush ppop ;
54 [ ] [ PV{ } 10000 [ push/pop-test ] times drop ] unit-test
58 10000 [ 1 swap ppush ] times
63 10000 >persistent-vector 752 [ ppop ] times dup length sequence=
70 16 random-bits [ "1" [ ppush ] change ] [ "2" get push ] bi
72 100 random "1" get length min [
76 "1" get "2" get sequence=