Skip to content

Commit

Permalink
Improve test robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Feb 22, 2025
1 parent 00aecdd commit ecf973a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/unit/Unit/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,16 @@ genWithLineComments = do

genWithBlockComments :: Gen ByteString
genWithBlockComments = do
xs <- G.list r genNonComment
-- Strip out forward slashes. Why? Consider the following scenario:
-- xs := ["foo/", "bar"]
-- cs := ["/* some comment */"]
-- shuffled := ["foo/", "/* some comment */", "bar"]
-- concat := "foo//* some comment */bar"
--
-- In other words, the concat turned the block comment into a line comment!
-- That's bad because we didn't generate the corresponding line end, i.e.
-- it is invalid.
xs <- G.list r $ (encodeUtf8 . T.replace "/" "") <$> genNonCommentTxt
cs <- G.list r genBlockComment
mconcat <$> G.shuffle (xs ++ cs)
where
Expand Down

0 comments on commit ecf973a

Please sign in to comment.