Skip to content

Commit 97a8909

Browse files
committed
Test multiline eval results
- add test for multiline show instance See #2907
1 parent b1bf549 commit 97a8909

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

plugins/hls-eval-plugin/test/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ tests =
6868
, goldenWithEval "Refresh an evaluation" "T5" "hs"
6969
, goldenWithEval "Refresh an evaluation w/ lets" "T6" "hs"
7070
, goldenWithEval "Refresh a multiline evaluation" "T7" "hs"
71+
, goldenWithEval "Evaluate a multi-line show result" "TMultiResult" "hs" -- Do not escape from comments!
7172
, testCase "Semantic and Lexical errors are reported" $ do
7273
evalInFile "T8.hs" "-- >>> noFunctionWithThisName" "-- Variable not in scope: noFunctionWithThisName"
7374
evalInFile "T8.hs" "-- >>> res = \"a\" + \"bc\"" $
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module TMultiResult where
2+
-- test multiline show instance (see #2907)
3+
4+
data Multiline = M {l1 :: String, l2 :: String} deriving Read
5+
6+
instance Show Multiline where
7+
show m = "M {\n l1=" <> show (l1 m) <> ",\n l2=" <> show (l2 m) <> "\n}"
8+
9+
-- >>> M "first line" "second line"
10+
-- M {
11+
-- l1="first line",
12+
-- l2="second line"
13+
-- }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module TMultiResult where
2+
-- test multiline show instance (see #2907)
3+
4+
data Multiline = M {l1 :: String, l2 :: String} deriving Read
5+
6+
instance Show Multiline where
7+
show m = "M {\n l1=" <> show (l1 m) <> ",\n l2=" <> show (l2 m) <> "\n}"
8+
9+
-- >>> M "first line" "second line"

0 commit comments

Comments
 (0)