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