1 USING: alien arrays bit-arrays kernel math random sequences
2 sequences.private tools.test ;
4 [ -1 <bit-array> ] [ T{ bad-array-length f -1 } = ] must-fail-with
6 { 100 } [ 100 <bit-array> length ] unit-test
11 3 <bit-array> t 0 pick set-nth t 2 pick set-nth
18 { t f t } >bit-array >array
24 { t f t } >bit-array dup clone [ not ] map!
31 { t f t t f } >bit-array dup clear-bits >array
37 { t f t t f } >bit-array dup set-bits >array
42 drop 100 [ 2 random zero? ] replicate
43 dup >bit-array >array =
48 1 2 { t f t f } <slice> >bit-array
51 { ?{ f t } } [ 0 2 ?{ f t f } subseq ] unit-test
53 { ?{ t f t f f f } } [ 6 ?{ t f t } resize ] unit-test
55 { ?{ t t } } [ 2 ?{ t t f t f t f t t t f t } resize ] unit-test
57 [ -10 ?{ } resize ] must-fail
59 [ -1 integer>bit-array ] must-fail
60 { ?{ } } [ 0 integer>bit-array ] unit-test
61 { ?{ f t } } [ 2 integer>bit-array ] unit-test
62 { ?{ t t t t t t t t t } } [ 511 integer>bit-array ] unit-test
64 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
65 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
66 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
67 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
69 0xffffffffffffffffffffffffffffffff integer>bit-array
72 { 14 } [ ?{ f t t t } bit-array>integer ] unit-test
73 { 0 } [ ?{ } bit-array>integer ] unit-test
74 { 0xffffffffffffffffffffffffffffffff } [ ?{
75 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
76 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
77 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
78 t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
79 } bit-array>integer ] unit-test
81 { 49 } [ 49 <bit-array> dup set-bits [ ] count-by ] unit-test
83 { 1 } [ ?{ f t f t } byte-length ] unit-test
85 { 0xa } [ ?{ f t f t } bit-array>integer ] unit-test
87 { 0x100 } [ ?{ f f f f f f f f t } bit-array>integer ] unit-test