Skip to content

Commit 3996b02

Browse files
committed
Add performance test for #205
When the timeout limit is raised, the test finishes after ~8s on my laptop.
1 parent 92cc704 commit 3996b02

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

  • prettyprinter/test/Testsuite

prettyprinter/test/Testsuite/Main.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ tests = testGroup "Tests"
5353
groupingPerformance
5454
, testCase "fillSep performance"
5555
fillSepPerformance
56+
, testCase "Issue 205"
57+
issue205
5658
]
5759
, testGroup "Regression tests"
5860
[ testCase "layoutSmart: softline behaves like a newline (#49)"
@@ -285,6 +287,24 @@ fillSepPerformance = docPerformanceTest (pathological 1000)
285287
pathological :: Int -> Doc ann
286288
pathological n = iterate (\x -> fillSep ["a", x <+> "b"] ) "foobar" !! n
287289

290+
issue205 :: Assertion
291+
issue205 = do
292+
let doc = fillSep (replicate 30 (sep ["abc", "xyz" :: Doc ()]))
293+
t = renderStrict (layoutSmart defaultLayoutOptions doc)
294+
timeout 1000000 (evaluate t) >>= \t' -> case t' of
295+
Nothing -> assertFailure "Timeout!"
296+
Just _success -> pure ()
297+
where
298+
{-
299+
docPerformanceTest doc
300+
= timeout 10000000 (forceDoc doc) >>= \doc' -> case doc' of
301+
Nothing -> assertFailure "Timeout!"
302+
Just _success -> pure ()
303+
where
304+
forceDoc :: Doc ann -> IO ()
305+
forceDoc = evaluate . foldr seq () . show
306+
-}
307+
288308
regressionLayoutSmartSoftline :: Assertion
289309
regressionLayoutSmartSoftline
290310
= let doc = "a" <> softline <> "b"

0 commit comments

Comments
 (0)