Skip to content

Commit

Permalink
Test multiline eval results
Browse files Browse the repository at this point in the history
- add test for multiline show instance

See #2907
  • Loading branch information
xsebek committed May 16, 2022
1 parent b1bf549 commit 97a8909
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/hls-eval-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tests =
, goldenWithEval "Refresh an evaluation" "T5" "hs"
, goldenWithEval "Refresh an evaluation w/ lets" "T6" "hs"
, goldenWithEval "Refresh a multiline evaluation" "T7" "hs"
, goldenWithEval "Evaluate a multi-line show result" "TMultiResult" "hs" -- Do not escape from comments!
, testCase "Semantic and Lexical errors are reported" $ do
evalInFile "T8.hs" "-- >>> noFunctionWithThisName" "-- Variable not in scope: noFunctionWithThisName"
evalInFile "T8.hs" "-- >>> res = \"a\" + \"bc\"" $
Expand Down
13 changes: 13 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TMultiResult.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module TMultiResult where
-- test multiline show instance (see #2907)

data Multiline = M {l1 :: String, l2 :: String} deriving Read

instance Show Multiline where
show m = "M {\n l1=" <> show (l1 m) <> ",\n l2=" <> show (l2 m) <> "\n}"

-- >>> M "first line" "second line"
-- M {
-- l1="first line",
-- l2="second line"
-- }
9 changes: 9 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TMultiResult.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module TMultiResult where
-- test multiline show instance (see #2907)

data Multiline = M {l1 :: String, l2 :: String} deriving Read

instance Show Multiline where
show m = "M {\n l1=" <> show (l1 m) <> ",\n l2=" <> show (l2 m) <> "\n}"

-- >>> M "first line" "second line"

0 comments on commit 97a8909

Please sign in to comment.