]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.tests: fix the test cases so they dont leak, and new tc for with-callback
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 22 Oct 2014 10:24:44 +0000 (12:24 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 22 Oct 2014 14:02:55 +0000 (07:02 -0700)
core/alien/alien-tests.factor

index 038d866786dd2b3dbf764248f36c29be83201079..34126e9227e1eca49db7c50966393a711cef1a35 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors alien alien.accessors alien.c-types alien.libraries
-alien.syntax arrays byte-arrays continuations destructors fry kernel
-kernel.private layouts libc math namespaces prettyprint sequences sets system
+alien.syntax arrays byte-arrays continuations fry kernel kernel.private
+layouts libc math namespaces prettyprint sequences sets system tools.memory
 tools.test ;
 FROM: namespaces => set ;
 IN: alien.tests
@@ -106,12 +106,21 @@ SYMBOL: foo
     [ 2drop 37 ] alien-callback ;
 
 : call-cb ( -- ret )
-    f f <cb-creator> \ int { pointer: void pointer: void } \ cdecl
-    alien-indirect ;
+    f f <cb-creator> [
+        \ 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
 { 37 37 } [
-    [ call-cb ] with-destructors
+    call-cb
     fill-and-free-callback-heap
-    [ call-cb ] with-destructors
+    call-cb
 ] unit-test