Skip to content

Commit

Permalink
Fix multiline eval plugin padding (haskell#2910)
Browse files Browse the repository at this point in the history
* Test multiline eval results

- add test for multiline show instance

See haskell#2907

* Fix multiline eval padding

See haskell#2907
  • Loading branch information
xsebek authored and sloorush committed May 21, 2022
1 parent b946d88 commit 9f5472e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,9 @@ runTests EvalConfig{..} e@(_st, _) tests = do
dbg "TEST RESULTS" rs

let checkedResult = testCheck eval_cfg_diff (section, test) rs
let resultLines = concatMap T.lines checkedResult

let edit = asEdit (sectionFormat section) test (map pad checkedResult)
let edit = asEdit (sectionFormat section) test (map pad resultLines)
dbg "TEST EDIT" edit
return edit

Expand Down
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 9f5472e

Please sign in to comment.