]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/c-types/c-types-tests.factor
Fix permission bits
[factor.git] / basis / alien / c-types / c-types-tests.factor
1 IN: alien.c-types.tests
2 USING: alien alien.syntax alien.c-types kernel tools.test
3 sequences system libc alien.strings io.encodings.utf8 ;
4
5 \ expand-constants must-infer
6
7 : xyz 123 ;
8
9 [ { "blah" 123 } ] [ { "blah" xyz } expand-constants ] unit-test
10
11 : foo ( -- n ) "fdafd" f dlsym [ 123 ] unless* ;
12
13 [ 123 ] [ foo ] unit-test
14
15 [ -1 ] [ -1 <char> *char ] unit-test
16 [ -1 ] [ -1 <short> *short ] unit-test
17 [ -1 ] [ -1 <int> *int ] unit-test
18
19 C-UNION: foo
20     "int"
21     "int" ;
22
23 [ f ] [ "char*" c-type "void*" c-type eq? ] unit-test
24 [ t ] [ "char**" c-type "void*" c-type eq? ] unit-test
25
26 [ t ] [ "foo" heap-size "int" heap-size = ] unit-test
27
28 TYPEDEF: int MyInt
29
30 [ t ] [ "int" c-type "MyInt" c-type eq? ] unit-test
31 [ t ] [ "void*" c-type "MyInt*" c-type eq? ] unit-test
32
33 TYPEDEF: char MyChar
34
35 [ t ] [ "char" c-type "MyChar" c-type eq? ] unit-test
36 [ f ] [ "void*" c-type "MyChar*" c-type eq? ] unit-test
37 [ t ] [ "char*" c-type "MyChar*" c-type eq? ] unit-test
38
39 [ 32 ] [ { "int" 8 } heap-size ] unit-test
40
41 TYPEDEF: char* MyString
42
43 [ t ] [ "char*" c-type "MyString" c-type eq? ] unit-test
44 [ t ] [ "void*" c-type "MyString*" c-type eq? ] unit-test
45
46 TYPEDEF: int* MyIntArray
47
48 [ t ] [ "void*" c-type "MyIntArray" c-type eq? ] unit-test
49
50 TYPEDEF: uchar* MyLPBYTE
51
52 [ t ] [ { "char*" utf8 } c-type "MyLPBYTE" c-type = ] unit-test
53
54 [
55     0 B{ 1 2 3 4 } <displaced-alien> <void*>
56 ] must-fail
57
58 [ t ] [ { t f t } >c-bool-array { 1 0 1 } >c-int-array = ] unit-test