Skip to content

Commit

Permalink
fix: replaceAll, render non-printing when strings not equal
Browse files Browse the repository at this point in the history
  • Loading branch information
cakekindel committed Nov 4, 2024
1 parent 7b5a704 commit bf117b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 7 additions & 2 deletions test/Prelude.purs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,20 @@ shouldEqualStr
-> String
-> m Unit
shouldEqualStr v1 v2 =
let
renderNonPrinting =
String.replaceAll (String.Pattern "\r") (String.Replacement "")
>>> String.replaceAll (String.Pattern "\t") (String.Replacement "␉-->")
in
when (v1 /= v2) do
fail $ Array.intercalate "\n"
[ ""
, "===== (Actual)"
, v1
, renderNonPrinting v1
, "====="
, ""
, "===== (Expected)"
, v2
, renderNonPrinting v2
, "====="
, ""
]
Expand Down
7 changes: 4 additions & 3 deletions test/Spago/Build.purs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ spec = Spec.around withTempDir do
{ stdoutFile: Nothing
, stderrFile: Just (fixture "purs-not-ok.txt")
, result: isLeft
, sanitize: String.trim
>>> String.replace (String.Pattern "Usage: purs.bin") (String.Replacement "Usage: purs")
>>> String.replace (String.Pattern "\r\n") (String.Replacement "\n")
, sanitize:
String.trim
>>> String.replaceAll (String.Pattern "Usage: purs.bin") (String.Replacement "Usage: purs")
>>> String.replaceAll (String.Pattern "\r\n") (String.Replacement "\n")
}

Spec.it "passes options to purs" \{ spago } -> do
Expand Down

0 comments on commit bf117b8

Please sign in to comment.