1 USING: alien alien.syntax alien.c-types alien.parser
2 eval kernel tools.test sequences system libc alien.strings
3 io.encodings.utf8 math.constants classes.struct classes ;
4 IN: alien.c-types.tests
8 [ 492 ] [ { int xyz } heap-size ] unit-test
10 [ -1 ] [ -1 <char> *char ] unit-test
11 [ -1 ] [ -1 <short> *short ] unit-test
12 [ -1 ] [ -1 <int> *int ] unit-test
18 [ f ] [ char resolve-pointer-type c-type void* c-type eq? ] unit-test
19 [ t ] [ char* resolve-pointer-type c-type void* c-type eq? ] unit-test
21 [ t ] [ foo heap-size int heap-size = ] unit-test
25 [ t ] [ int c-type MyInt c-type eq? ] unit-test
26 [ t ] [ void* c-type MyInt resolve-pointer-type c-type eq? ] unit-test
30 [ t ] [ char c-type MyChar c-type eq? ] unit-test
31 [ f ] [ void* c-type MyChar resolve-pointer-type c-type eq? ] unit-test
32 [ t ] [ char* c-type MyChar resolve-pointer-type c-type eq? ] unit-test
34 [ 32 ] [ { int 8 } heap-size ] unit-test
36 TYPEDEF: char* MyString
38 [ t ] [ char* c-type MyString c-type eq? ] unit-test
39 [ t ] [ void* c-type MyString resolve-pointer-type c-type eq? ] unit-test
41 TYPEDEF: int* MyIntArray
43 [ t ] [ void* c-type MyIntArray c-type eq? ] unit-test
45 TYPEDEF: uchar* MyLPBYTE
47 [ t ] [ { char* utf8 } c-type MyLPBYTE c-type = ] unit-test
50 0 B{ 1 2 3 4 } <displaced-alien> <void*>
53 os windows? cpu x86.64? and [
54 [ -2147467259 ] [ 2147500037 <long> *long ] unit-test
57 [ 0 ] [ -10 uchar c-type-clamp ] unit-test
58 [ 12 ] [ 12 uchar c-type-clamp ] unit-test
59 [ -10 ] [ -10 char c-type-clamp ] unit-test
60 [ 127 ] [ 230 char c-type-clamp ] unit-test
61 [ t ] [ pi dup float c-type-clamp = ] unit-test
65 [ t ] [ void* c-type opaque resolve-pointer-type c-type eq? ] unit-test
66 [ opaque c-type ] [ no-c-type? ] must-fail-with
70 IN: alien.c-types.tests
71 FUNCTION: opaque return_opaque ( ) ;
72 """ eval( -- ) ] [ no-c-type? ] must-fail-with
75 STRUCT: backward { x forward* } ;
76 STRUCT: forward { x backward* } ;
78 [ t ] [ forward c-type struct-c-type? ] unit-test
79 [ t ] [ backward c-type struct-c-type? ] unit-test
81 DEFER: struct-redefined
87 USING: alien.c-types classes.struct ;
88 IN: alien.c-types.tests
90 STRUCT: struct-redefined { x int } ;
95 IN: alien.c-types.tests
97 C-TYPE: struct-redefined
100 \ struct-redefined class?