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