diff options
Diffstat (limited to 'testsuite/tests/lib/should_run/weak001.hs')
-rw-r--r-- | testsuite/tests/lib/should_run/weak001.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/tests/lib/should_run/weak001.hs b/testsuite/tests/lib/should_run/weak001.hs new file mode 100644 index 0000000000..60dc9c4a12 --- /dev/null +++ b/testsuite/tests/lib/should_run/weak001.hs @@ -0,0 +1,12 @@ +import Foreign +import System.Mem.Weak + +kill:: Ptr a -> IO () +kill a = do + w <- mkWeakPtr a Nothing + addFinalizer a $ + deRefWeak w >> return () + +main:: IO () +main = sequence_ . take 10000 . repeat $ + mallocBytes 100 >>= kill >> return () |