]> gitweb.factorcode.org Git - factor.git/blob - basis/specialized-arrays/specialized-arrays-tests.factor
Merge branch 'master' into simd
[factor.git] / basis / specialized-arrays / specialized-arrays-tests.factor
1 IN: specialized-arrays.tests
2 USING: tools.test specialized-arrays sequences
3 specialized-arrays.int specialized-arrays.bool
4 specialized-arrays.ushort alien.c-types accessors kernel
5 specialized-arrays.direct.int specialized-arrays.char
6 specialized-arrays.uint specialized-arrays.float
7 arrays combinators compiler ;
8
9 [ t ] [ { 1 2 3 } >int-array int-array? ] unit-test
10
11 [ t ] [ int-array{ 1 2 3 } int-array? ] unit-test
12
13 [ 2 ] [ int-array{ 1 2 3 } second ] unit-test
14
15 [ t ] [
16     { t f t } >bool-array underlying>>
17     { 1 0 1 } "bool" heap-size {
18         { 1 [ >char-array ] }
19         { 4 [ >uint-array ] }
20     } case underlying>> =
21 ] unit-test
22
23 [ ushort-array{ 1234 } ] [
24     little-endian? B{ 210 4 } B{ 4 210 } ? byte-array>ushort-array
25 ] unit-test
26
27 [ B{ 210 4 1 } byte-array>ushort-array ] must-fail
28
29 [ { 3 1 3 3 7 } ] [
30     int-array{ 3 1 3 3 7 } malloc-byte-array 5 <direct-int-array> >array
31 ] unit-test
32
33 [ f ] [ float-array{ 4 3 2 1 } dup clone [ underlying>> ] bi@ eq? ] unit-test
34
35 [ f ] [ [ float-array{ 4 3 2 1 } dup clone [ underlying>> ] bi@ eq? ] compile-call ] unit-test