alien.tests: fix the test cases so they dont leak, and new tc for with-callback
parent
aad8d4b8d6
commit
65e460cf57
|
@ -1,6 +1,6 @@
|
||||||
USING: accessors alien alien.accessors alien.c-types alien.libraries
|
USING: accessors alien alien.accessors alien.c-types alien.libraries
|
||||||
alien.syntax arrays byte-arrays continuations destructors fry kernel
|
alien.syntax arrays byte-arrays continuations fry kernel kernel.private
|
||||||
kernel.private layouts libc math namespaces prettyprint sequences sets system
|
layouts libc math namespaces prettyprint sequences sets system tools.memory
|
||||||
tools.test ;
|
tools.test ;
|
||||||
FROM: namespaces => set ;
|
FROM: namespaces => set ;
|
||||||
IN: alien.tests
|
IN: alien.tests
|
||||||
|
@ -106,12 +106,21 @@ SYMBOL: foo
|
||||||
[ 2drop 37 ] alien-callback ;
|
[ 2drop 37 ] alien-callback ;
|
||||||
|
|
||||||
: call-cb ( -- ret )
|
: call-cb ( -- ret )
|
||||||
f f <cb-creator> \ int { pointer: void pointer: void } \ cdecl
|
f f <cb-creator> [
|
||||||
alien-indirect ;
|
\ int { pointer: void pointer: void } \ cdecl
|
||||||
|
alien-indirect
|
||||||
|
] with-callback ;
|
||||||
|
|
||||||
|
! This function shouldn't leak
|
||||||
|
{ t } [
|
||||||
|
callback-room occupied>>
|
||||||
|
call-cb drop
|
||||||
|
callback-room occupied>> =
|
||||||
|
] unit-test
|
||||||
|
|
||||||
! Will fail if the callbacks cache gets out of sync
|
! Will fail if the callbacks cache gets out of sync
|
||||||
{ 37 37 } [
|
{ 37 37 } [
|
||||||
[ call-cb ] with-destructors
|
call-cb
|
||||||
fill-and-free-callback-heap
|
fill-and-free-callback-heap
|
||||||
[ call-cb ] with-destructors
|
call-cb
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
Loading…
Reference in New Issue