factor/basis/compiler/tests/redefine24.factor

40 lines
941 B
Factor
Raw Normal View History

USING: alien alien.syntax eval math tools.test ;
QUALIFIED: alien.c-types
IN: compiler.tests.redefine24
2017-12-29 02:31:02 -05:00
TYPEDEF: alien.c-types::int type-1
2017-12-29 02:31:02 -05:00
TYPEDEF: alien.c-types::int type-3
: callback ( -- ptr )
2010-03-31 22:20:35 -04:00
type-3 { type-1 type-1 } cdecl [ + >integer ] alien-callback ;
2017-12-29 02:31:02 -05:00
TYPEDEF: alien.c-types::float type-2
: indirect ( x y ptr -- z )
2010-03-31 22:20:35 -04:00
type-3 { type-2 type-2 } cdecl alien-indirect ;
[ ] [
"USING: alien.c-types alien.syntax ;
IN: compiler.tests.redefine24 TYPEDEF: int type-2" eval( -- )
] unit-test
[ 3 ] [ 1 2 callback indirect ] unit-test
[ ] [
"USING: alien.c-types alien.syntax ;
IN: compiler.tests.redefine24
TYPEDEF: float type-1
TYPEDEF: float type-2" eval( -- )
] unit-test
[ 3 ] [ 1.0 2.0 callback indirect ] unit-test
[ ] [
"USING: alien.c-types alien.syntax ;
IN: compiler.tests.redefine24
TYPEDEF: float type-3" eval( -- )
] unit-test
[ 3.0 ] [ 1.0 2.0 callback indirect ] unit-test