Skip to content

Commit

Permalink
GHC.DiagnosticSpec: Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Oct 23, 2024
1 parent 5852876 commit 47727a1
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/GHC/DiagnosticSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test name = it name $ do
bin <- lookupGhc <$> getEnvironment
let
process :: CreateProcess
process = proc bin (args ++ [dir </> "Foo.hs"])
process = proc bin ("-fno-code" : args ++ [dir </> "Foo.hs"])
(_, _, err) <- readCreateProcessWithExitCode process ""
return err

Expand All @@ -51,3 +51,6 @@ spec = do
test "variable-not-in-scope-perhaps-use"
test "use-BlockArguments"
test "non-existing"
test "parse-error"
test "lex-error"
test "multiple-error-messages"
3 changes: 3 additions & 0 deletions test/assets/lex-error/Foo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Foo where

foo = "bar
1 change: 1 addition & 0 deletions test/assets/lex-error/err.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"1.0","ghcVersion":"ghc-9.10.1","span":{"file":"test/assets/lex-error/Foo.hs","start":{"line":3,"column":11},"end":{"line":3,"column":11}},"severity":"Error","code":21231,"message":["lexical error in string/character literal at character '\\n'"],"hints":[]}
3 changes: 3 additions & 0 deletions test/assets/lex-error/err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/assets/lex-error/Foo.hs:3:11: error: [GHC-21231]
lexical error in string/character literal at character '\n'

3 changes: 3 additions & 0 deletions test/assets/multiple-error-messages/Foo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Foo where

foo = "foo" + 23
1 change: 1 addition & 0 deletions test/assets/multiple-error-messages/err.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"1.0","ghcVersion":"ghc-9.10.1","span":{"file":"test/assets/multiple-error-messages/Foo.hs","start":{"line":3,"column":13},"end":{"line":3,"column":14}},"severity":"Error","code":39999,"message":["No instance for `Num String' arising from a use of `+'","In the expression: \"foo\" + 23\nIn an equation for `foo': foo = \"foo\" + 23"],"hints":[]}
5 changes: 5 additions & 0 deletions test/assets/multiple-error-messages/err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test/assets/multiple-error-messages/Foo.hs:3:13: error: [GHC-39999]
• No instance for `Num String' arising from a use of `+'
• In the expression: "foo" + 23
In an equation for `foo': foo = "foo" + 23

3 changes: 3 additions & 0 deletions test/assets/parse-error/Foo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Foo where

data foo
1 change: 1 addition & 0 deletions test/assets/parse-error/err.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"1.0","ghcVersion":"ghc-9.10.1","span":{"file":"test/assets/parse-error/Foo.hs","start":{"line":3,"column":6},"end":{"line":3,"column":9}},"severity":"Error","code":47568,"message":["Malformed head of type or class declaration: foo"],"hints":[]}
3 changes: 3 additions & 0 deletions test/assets/parse-error/err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/assets/parse-error/Foo.hs:3:6: error: [GHC-47568]
Malformed head of type or class declaration: foo

0 comments on commit 47727a1

Please sign in to comment.