]> gitweb.factorcode.org Git - factor.git/blob - basis/sequences/complex/complex-tests.factor
Specialized array overhaul
[factor.git] / basis / sequences / complex / complex-tests.factor
1 USING: specialized-arrays sequences.complex
2 kernel sequences tools.test arrays accessors ;
3 SPECIALIZED-ARRAY: float
4 IN: sequences.complex.tests
5
6 : test-array ( -- x )
7     float-array{ 1.0 2.0 3.0 4.0 } clone <complex-sequence> ;
8 : odd-length-test-array ( -- x )
9     float-array{ 1.0 2.0 3.0 4.0 5.0 } clone <complex-sequence> ;
10
11 [ 2 ] [ test-array length ] unit-test
12 [ 2 ] [ odd-length-test-array length ] unit-test
13
14 [ C{ 1.0 2.0 } ] [ test-array first ] unit-test
15 [ C{ 3.0 4.0 } ] [ test-array second ] unit-test
16
17 [ { C{ 1.0 2.0 } C{ 3.0 4.0 } } ]
18 [ test-array >array ] unit-test
19
20 [ float-array{ 1.0 2.0 5.0 6.0 } ]
21 [ test-array [ C{ 5.0 6.0 } 1 rot set-nth ] [ seq>> ] bi ]
22 unit-test
23
24 [ float-array{ 7.0 0.0 3.0 4.0 } ]
25 [ test-array [ 7.0 0 rot set-nth ] [ seq>> ] bi ]
26 unit-test
27