Skip to content

Commit dea714a

Browse files
authored
More inline comments on the space leak regression test
1 parent 54bcfdd commit dea714a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/Regressions.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ issue254Lazy = issue254LazyLambda 2
9999
{-# NOINLINE issue254LazyLambda #-}
100100
issue254LazyLambda :: Int -> Assertion
101101
issue254LazyLambda i = do
102-
_ <- return ()
102+
_ <- return () -- put oldV under a lambda
103103
let oldV = error $ "Should not be evaluated: " ++ show i
104-
weakV <- mkWeakPtr oldV Nothing
104+
weakV <- mkWeakPtr oldV Nothing -- test whether oldV is alive
105105
let mp = HML.insert (KC 1) (error "Should not be evaluated") $ HML.fromList [(KC 0, "1"), (KC 1, oldV)]
106-
_ <- evaluate mp
106+
_ <- evaluate mp -- force the insert to happen
107107
performGC
108-
res <- deRefWeak weakV
109-
_ <- evaluate mp
108+
res <- deRefWeak weakV -- gives Just if oldV is still alive
109+
_ <- evaluate mp -- makes sure that we didn't GC away the whole HashMap, just oldV
110110
assert $ isNothing res
111111

112112
-- Like issue254Lazy, but using strict HashMap

0 commit comments

Comments
 (0)