Skip to content

Commit

Permalink
Remove doctests available elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 31, 2024
1 parent ef56763 commit b638eac
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions cabal-testsuite/src/Test/Cabal/NeedleHaystack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,6 @@ output) with `concatOutput` before checking if it contained the expected value.
This function, now renamed as `lineBreaksToSpaces`, would remove CR values and
convert LF values to spaces.
> -- | Replace line breaks with spaces, correctly handling @"\\r\\n"@.
> --
> -- >>> lineBreaksToSpaces "foo\nbar\r\nbaz"
> -- "foo bar baz"
> --
> -- >>> lineBreaksToSpaces "foo\nbar\r\nbaz\n"
> -- "foo bar baz"
> --
> -- >>> lineBreaksToSpaces "\nfoo\nbar\r\nbaz\n"
> -- " foo bar baz"
> lineBreaksToSpaces :: String -> String
With this setup, false positives were possible. An expected value using string
gaps and spaces would match a `concatOutput` modified actual value of
"foo_bar_baz", where '_' was any of space, LF or CRLF in the unmodified actual
Expand Down Expand Up @@ -132,48 +120,9 @@ and the haystack (the actual output) can optionally be shown this way too.
This is still a lenient match, allowing LF to match CRLF, but `encodeLf` doesn't
replace LF with spaces like `concatOutput` (`lineBreaksToSpaces`) did:
> -- | Replace line CRLF line breaks with LF line breaks.
> --
> -- >>> encodeLf "foo\nbar\r\nbaz"
> -- "foo\nbar\nbaz"
> --
> -- >>> encodeLf "foo\nbar\r\nbaz\n"
> -- "foo\nbar\nbaz\n"
> --
> -- >>> encodeLf "\nfoo\nbar\r\nbaz\n"
> -- "\nfoo\nbar\nbaz\n"
> --
> -- >>> encodeLf "\n\n\n"
> -- "\n\n\n"
> encodeLf :: String -> String
If you choose to display the actual value by setting
`NeedleHaystack{displayHaystack = True}` then its lines will be delimited.
> -- | Mark lines with visible delimiters, @^@ at the start and @$@ at the end.
> --
> -- >>> delimitLines ""
> -- "^$"
> --
> -- >>> delimitLines "\n"
> -- "^$\n"
> --
> -- >>> delimitLines "\n\n"
> -- "^$\n^$\n"
> --
> -- >>> delimitLines "\n\n\n"
> -- "^$\n^$\n^$\n"
> --
> -- >>> delimitLines $ encodeLf "foo\nbar\r\nbaz"
> -- "^foo$\n^bar$\n^baz$"
> --
> -- >>> delimitLines $ encodeLf "foo\nbar\r\nbaz\n"
> -- "^foo$\n^bar$\n^baz$\n"
> --
> -- >>> delimitLines $ encodeLf "\nfoo\nbar\r\nbaz\n"
> -- "^$\n^foo$\n^bar$\n^baz$\n"
> delimitLines:: String -> String
With `assertOn`, supplying string transformation to both the needle and haystack
before comparison and before display can help find out why an expected value is
or isn't found in the test output.
Expand Down

0 comments on commit b638eac

Please sign in to comment.