Backport from sid to buster
[hcoop/debian/mlton.git] / regression / finalize.4.sml
CommitLineData
7f918cf1
CE
1fun test (str : string) =
2 let open MLton.Finalizable
3 val x = new str
4 in addFinalizer (x, fn s => print (s ^ ": finalizer\n"));
5 withValue (x, fn s =>
6 (print "before GC 5\n";
7 MLton.GC.collect ();
8 print "after GC 5\n";
9 (fn () => (print "invoking touch\n"; touch x))))
10 end
11
12val _ = (print "before test 5\n";
13 let val t = test "test 5"
14 in print "before GC 5a\n";
15 MLton.GC.collect ();
16 print "after GC 5a\n";
17 t ();
18 print "before GC 5b\n";
19 MLton.GC.collect ();
20 print "after GC 5b\n"
21 end;
22 print "before GC 5c\n";
23 MLton.GC.collect ();
24 print "after GC 5c\n")