1 structure Weak
= MLton
.Weak
6 then raise Fail
"bug int"
9 fun testIntInf (i
: IntInf
.int) =
14 NONE
=> raise Fail
"bug IntInf"
15 | SOME i
=> print (concat
[IntInf
.toString i
, "\n"])
20 val _
= testIntInf
12345678901234567890
24 val rs
= Array
.tabulate (n
, ref
)
25 val ws
= Array
.tabulate (n
, fn i
=> Weak
.new (Array
.sub (rs
, i
)))
26 fun isAlive i
= isSome (Weak
.get (Array
.sub (ws
, i
)))
27 val _
= MLton
.GC
.collect ()
29 if isAlive
0 andalso isAlive
1
31 else raise Fail
"bug1"
32 fun clear i
= Array
.update (rs
, i
, r
)
33 fun sub i
= ! (Array
.sub (rs
, i
))
34 fun pi x
= print (concat
[Int.toString x
, "\n"])
35 val _
= pi (sub
0 + sub
1)
36 val _
= valOf (Weak
.get (Array
.sub (ws
, 0))) := 12345
38 val _
= MLton
.GC
.collect ()
40 if isAlive
0 andalso not (isAlive
1)
42 else raise Fail
"bug2"
45 val _
= MLton
.GC
.collect ()
47 if not (isAlive
0) andalso not (isAlive
1)
49 else raise Fail
"bug2"