[MLton-commit] r4047
Stephen Weeks
MLton@mlton.org
Fri, 26 Aug 2005 21:28:28 -0700
Added MLton.Finalizable regression sent by Florian Weimer.
----------------------------------------------------------------------
A mlton/trunk/regression/finalize.4.ok
A mlton/trunk/regression/finalize.4.sml
----------------------------------------------------------------------
Added: mlton/trunk/regression/finalize.4.ok
===================================================================
--- mlton/trunk/regression/finalize.4.ok 2005-08-27 04:18:12 UTC (rev 4046)
+++ mlton/trunk/regression/finalize.4.ok 2005-08-27 04:28:23 UTC (rev 4047)
@@ -0,0 +1,11 @@
+before test 5
+before GC 5
+after GC 5
+before GC 5a
+after GC 5a
+invoking touch
+before GC 5b
+test 5: finalizer
+after GC 5b
+before GC 5c
+after GC 5c
Added: mlton/trunk/regression/finalize.4.sml
===================================================================
--- mlton/trunk/regression/finalize.4.sml 2005-08-27 04:18:12 UTC (rev 4046)
+++ mlton/trunk/regression/finalize.4.sml 2005-08-27 04:28:23 UTC (rev 4047)
@@ -0,0 +1,24 @@
+fun test (str : string) =
+ let open MLton.Finalizable
+ val x = new str
+ in addFinalizer (x, fn s => print (s ^ ": finalizer\n"));
+ withValue (x, fn s =>
+ (print "before GC 5\n";
+ MLton.GC.collect ();
+ print "after GC 5\n";
+ (fn () => (print "invoking touch\n"; touch x))))
+ end
+
+val _ = (print "before test 5\n";
+ let val t = test "test 5"
+ in print "before GC 5a\n";
+ MLton.GC.collect ();
+ print "after GC 5a\n";
+ t ();
+ print "before GC 5b\n";
+ MLton.GC.collect ();
+ print "after GC 5b\n"
+ end;
+ print "before GC 5c\n";
+ MLton.GC.collect ();
+ print "after GC 5c\n")