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