]> gitweb.factorcode.org Git - factor.git/blob - core/alien/c-types/c-types-tests.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / core / 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 : foo ( -- n ) "fdafd" f dlsym [ 123 ] unless* ;
6
7 [ 123 ] [ foo ] unit-test
8
9 [ -1 ] [ -1 <char> *char ] unit-test
10 [ -1 ] [ -1 <short> *short ] unit-test
11 [ -1 ] [ -1 <int> *int ] unit-test
12
13 C-UNION: foo
14     "int"
15     "int" ;
16
17 [ f ] [ "char*" c-type "void*" c-type eq? ] unit-test
18 [ t ] [ "char**" c-type "void*" c-type eq? ] unit-test
19
20 [ t ] [ "foo" heap-size "int" heap-size = ] unit-test
21
22 TYPEDEF: int MyInt
23
24 [ t ] [ "int" c-type "MyInt" c-type eq? ] unit-test
25 [ t ] [ "void*" c-type "MyInt*" c-type eq? ] unit-test
26
27 TYPEDEF: char MyChar
28
29 [ t ] [ "char" c-type "MyChar" c-type eq? ] unit-test
30 [ f ] [ "void*" c-type "MyChar*" c-type eq? ] unit-test
31 [ t ] [ "char*" c-type "MyChar*" c-type eq? ] unit-test
32
33 [ 32 ] [ { "int" 8 } heap-size ] unit-test
34
35 TYPEDEF: char* MyString
36
37 [ t ] [ "char*" c-type "MyString" c-type eq? ] unit-test
38 [ t ] [ "void*" c-type "MyString*" c-type eq? ] unit-test
39
40 TYPEDEF: int* MyIntArray
41
42 [ t ] [ "void*" c-type "MyIntArray" c-type eq? ] unit-test
43
44 TYPEDEF: uchar* MyLPBYTE
45
46 [ t ] [ { "char*" utf8 } c-type "MyLPBYTE" c-type = ] unit-test
47
48 [
49     0 B{ 1 2 3 4 } <displaced-alien> <void*>
50 ] must-fail
51
52 [ t ] [ { t f t } >c-bool-array { 1 0 1 } >c-int-array = ] unit-test