]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/data/data-tests.factor
Move <ref>, deref and little-endian? from alien.c-types to alien.data, remove <c...
[factor.git] / basis / alien / data / data-tests.factor
1 USING: alien alien.c-types alien.data alien.syntax
2 classes.struct kernel sequences specialized-arrays
3 specialized-arrays.private tools.test compiler.units vocabs ;
4 IN: alien.data.tests
5
6
7 [ -1 ] [ -1 char <ref> char deref ] unit-test
8 [ -1 ] [ -1 short <ref> short deref ] unit-test
9 [ -1 ] [ -1 int <ref> int deref ] unit-test
10
11 ! I don't care if this throws an error or works, but at least
12 ! it should be consistent between platforms
13 [ -1 ] [ -1.0 int <ref> int deref ] unit-test
14 [ -1 ] [ -1.0 long <ref> long deref ] unit-test
15 [ -1 ] [ -1.0 longlong <ref> longlong deref ] unit-test
16 [ 1 ] [ 1.0 uint <ref> uint deref ] unit-test
17 [ 1 ] [ 1.0 ulong <ref> ulong deref ] unit-test
18 [ 1 ] [ 1.0 ulonglong <ref> ulonglong deref ] unit-test
19
20 [
21     0 B{ 1 2 3 4 } <displaced-alien> void* <ref>
22 ] must-fail
23
24 os windows? cpu x86.64? and [
25     [ -2147467259 ] [ 2147500037 long <ref> long deref ] unit-test
26 ] when
27
28 STRUCT: foo { a int } { b void* } { c bool } ;
29
30 SPECIALIZED-ARRAY: foo
31
32 [ t ] [ 0 binary-zero? ] unit-test
33 [ f ] [ 1 binary-zero? ] unit-test
34 [ f ] [ -1 binary-zero? ] unit-test
35 [ t ] [ 0.0 binary-zero? ] unit-test
36 [ f ] [ 1.0 binary-zero? ] unit-test
37 [ f ] [ -0.0 binary-zero? ] unit-test
38 [ t ] [ C{ 0.0 0.0 } binary-zero? ] unit-test
39 [ f ] [ C{ 1.0 0.0 } binary-zero? ] unit-test
40 [ f ] [ C{ -0.0 0.0 } binary-zero? ] unit-test
41 [ f ] [ C{ 0.0 1.0 } binary-zero? ] unit-test
42 [ f ] [ C{ 0.0 -0.0 } binary-zero? ] unit-test
43 [ t ] [ f binary-zero? ] unit-test
44 [ t ] [ 0 <alien> binary-zero? ] unit-test
45 [ f ] [ 1 <alien> binary-zero? ] unit-test
46 [ f ] [ B{ } binary-zero? ] unit-test
47 [ t ] [ S{ foo f 0 f f } binary-zero? ] unit-test
48 [ f ] [ S{ foo f 1 f f } binary-zero? ] unit-test
49 [ f ] [ S{ foo f 0 ALIEN: 8 f } binary-zero? ] unit-test
50 [ f ] [ S{ foo f 0 f t } binary-zero? ] unit-test
51 [ t t f ] [
52     foo-array{
53         S{ foo f 0 f f }
54         S{ foo f 0 f f }
55         S{ foo f 1 f f }
56     } [ first binary-zero? ] [ second binary-zero? ] [ third binary-zero? ] tri
57 ] unit-test
58
59 [ ] [
60     [
61         foo specialized-array-vocab forget-vocab
62     ] with-compilation-unit
63 ] unit-test