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