Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiline eval plugin padding #2910

Merged
merged 2 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I am unsure why we get [Text] that does not have the show result split into lines.

We might want to consider splitting in the evals function. 🤷‍♂️


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"
-- }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only tests -- comments, but I figured {- -} would be fine and covered by the other multiline tests.

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"