Skip to content

Commit a5342e4

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 a5342e4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • prettyprinter/test/Testsuite

prettyprinter/test/Testsuite/Main.hs

Lines changed: 10 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,14 @@ 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+
288298
regressionLayoutSmartSoftline :: Assertion
289299
regressionLayoutSmartSoftline
290300
= let doc = "a" <> softline <> "b"

0 commit comments

Comments
 (0)