Skip to content

Commit 1b257dd

Browse files
language-nix/test: report how many tested identifiers need quoting
Currently this is practically > 95% which isn't great. Presumably, the examples for simple identifiers are very short as well.
1 parent e124dab commit 1b257dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

language-nix/test/hspec.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ main = hspec $ do
2121

2222
describe "HasParser Identifier" $ do
2323
it "can parse the result of prettyShow" $
24-
property $ \i -> parseM "Identifier" (prettyShow i) == Just (i :: Identifier)
24+
identProperty $ \i -> parseM "Identifier" (prettyShow i) == Just (i :: Identifier)
2525
it "can parse the result of quote" $
2626
stringIdentProperty $ \str -> parseM "Identifier" (quote str) == Just (ident # str)
2727

2828
stringIdentProperty :: (String -> Bool) -> Property
2929
stringIdentProperty p = property $ \s ->
30-
'\0' `notElem` s ==> p s
30+
'\0' `notElem` s ==> classify (needsQuoting s) "need quoting" $ p s
31+
32+
identProperty :: (Identifier -> Bool) -> Property
33+
identProperty p = property $ \i ->
34+
classify (needsQuoting (from ident # i)) "need quoting" $ p i

0 commit comments

Comments
 (0)