1 ! Copyright (C) 2009 Jeremy Hughes.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.inline.syntax alien.marshall.syntax destructors
4 tools.test accessors kernel ;
5 IN: alien.marshall.syntax.tests
12 C-INCLUDE: <stdbool.h>
14 CM-FUNCTION: void outarg1 ( int* a )
18 CM-FUNCTION: unsigned-long* outarg2 ( unsigned-long a, unsigned-long* b )
19 unsigned long* x = malloc(sizeof(unsigned long*));
26 { "double" "degrees" } ;
32 CM-FUNCTION: double hours ( sundial* d )
33 return d->wedge.degrees / 30;
36 CM-FUNCTION: void change_time ( double hours, sundial* d )
37 d->wedge.degrees = hours * 30;
40 CM-FUNCTION: bool c_not ( bool p )
44 CM-FUNCTION: char* upcase ( const-char* s )
46 char* t = malloc(sizeof(char) * len);
48 for (i = 0; i < len; i++)
56 { 1 1 } [ outarg1 ] must-infer-as
57 [ 3 ] [ 1 outarg1 ] unit-test
58 [ 3 ] [ t outarg1 ] unit-test
59 [ 2 ] [ f outarg1 ] unit-test
61 { 2 2 } [ outarg2 ] must-infer-as
62 [ 18 15 ] [ 3 5 outarg2 ] unit-test
64 { 1 1 } [ hours ] must-infer-as
65 [ 5.0 ] [ <sundial> <wedge> 150 >>degrees >>wedge hours ] unit-test
67 { 2 0 } [ change_time ] must-infer-as
68 [ 150.0 ] [ 5 <sundial> <wedge> 11 >>degrees >>wedge [ change_time ] keep wedge>> degrees>> ] unit-test
70 { 1 1 } [ c_not ] must-infer-as
71 [ f ] [ "x" c_not ] unit-test
72 [ f ] [ 0 c_not ] unit-test
74 { 1 1 } [ upcase ] must-infer-as
75 [ "ABC" ] [ "abc" upcase ] unit-test