Skip to content

Commit

Permalink
Add regression test for #382
Browse files Browse the repository at this point in the history
  • Loading branch information
sjakobi committed Mar 20, 2022
1 parent 967ba0e commit cb71632
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Regressions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,23 @@ issue379LazyUnionWith = do
touch v -- makes sure that we didn't GC away the combined value
assert $ isNothing res

------------------------------------------------------------------------
-- Issue #382
--
issue382 :: Assertion
issue382 = do
i :: Int <- randomIO
let k = SC (show i)
weakK <- mkWeakPtr k Nothing -- add the ability to test whether k is alive
let f :: Int -> Int -> Int
f x = error ("Should not be evaluated " ++ show x)
let m = HML.fromListWith f [(k, 1), (k, 2)]
Just v <- evaluate $ HML.lookup k m
performGC
res <- deRefWeak weakK -- gives Just if k is still alive
touch v -- makes sure that we didn't GC away the combined value
assert $ isNothing res

------------------------------------------------------------------------
-- * Test list

Expand All @@ -206,4 +223,7 @@ tests = testGroup "Regression tests"
, testCase "Strict.unionWithKey" issue379StrictUnionWithKey
#endif
]
#ifdef HAVE_NOTHUNKS
, testCase "issue382" issue382
#endif
]

0 comments on commit cb71632

Please sign in to comment.