]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/c-types/c-types-tests.factor
Merge branch 'master' of git://factorcode.org/git/factor
[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 CONSTANT: xyz 123
8
9 [ { "blah" 123 } ] [ { "blah" xyz } expand-constants ] unit-test
10
11 [ -1 ] [ -1 <char> *char ] unit-test
12 [ -1 ] [ -1 <short> *short ] unit-test
13 [ -1 ] [ -1 <int> *int ] unit-test
14
15 C-UNION: foo
16     "int"
17     "int" ;
18
19 [ f ] [ "char*" c-type "void*" c-type eq? ] unit-test
20 [ t ] [ "char**" c-type "void*" c-type eq? ] unit-test
21
22 [ t ] [ "foo" heap-size "int" heap-size = ] unit-test
23
24 TYPEDEF: int MyInt
25
26 [ t ] [ "int" c-type "MyInt" c-type eq? ] unit-test
27 [ t ] [ "void*" c-type "MyInt*" c-type eq? ] unit-test
28
29 TYPEDEF: char MyChar
30
31 [ t ] [ "char" c-type "MyChar" c-type eq? ] unit-test
32 [ f ] [ "void*" c-type "MyChar*" c-type eq? ] unit-test
33 [ t ] [ "char*" c-type "MyChar*" c-type eq? ] unit-test
34
35 [ 32 ] [ { "int" 8 } heap-size ] unit-test
36
37 TYPEDEF: char* MyString
38
39 [ t ] [ "char*" c-type "MyString" c-type eq? ] unit-test
40 [ t ] [ "void*" c-type "MyString*" c-type eq? ] unit-test
41
42 TYPEDEF: int* MyIntArray
43
44 [ t ] [ "void*" c-type "MyIntArray" c-type eq? ] unit-test
45
46 TYPEDEF: uchar* MyLPBYTE
47
48 [ t ] [ { "char*" utf8 } c-type "MyLPBYTE" c-type = ] unit-test
49
50 [
51     0 B{ 1 2 3 4 } <displaced-alien> <void*>
52 ] must-fail
53
54 os windows? cpu x86.64? and [
55     [ -2147467259 ] [ 2147500037 <long> *long ] unit-test
56 ] when