https://github.com/axelson/multiline_doctest_repro
https://github.com/axelson/multiline_doctest_repro
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/axelson/multiline_doctest_repro
- Owner: axelson
- Created: 2023-09-16T19:41:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-16T19:42:09.000Z (almost 3 years ago)
- Last Synced: 2025-03-29T09:05:40.412Z (about 1 year ago)
- Language: Elixir
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HdDoctest
Reproduces a limitation with multiline exceptions in doctests
To reproduce run:
- `mix test`
This will result in an error like:
```
1) doctest module HdDoctest (1) (HdDoctestTest)
test/hd_doctest_test.exs:3
Doctest failed: wrong message for ArgumentError
expected:
""
actual:
"errors were found at the given arguments:\n\n * 1st argument: not a nonempty list\n"
doctest:
iex> hd([])
** (ArgumentError)
stacktrace:
lib/hd_doctest.ex:4: HdDoctest (module)
```
But if you changing the expected error to not include the double newline results in the text after the newline being ignored:
```elixir
iex> hd([])
** (ArgumentError) errors were found at the given arguments:\n\n * 1st argument: not a nonempty list
```
```
1) doctest module HdDoctest (1) (HdDoctestTest)
test/hd_doctest_test.exs:3
Doctest failed: wrong message for ArgumentError
expected:
"errors were found at the given arguments:"
actual:
"errors were found at the given arguments:\n\n * 1st argument: not a nonempty list\n"
doctest:
iex> hd([])
** (ArgumentError) errors were found at the given arguments:
stacktrace:
lib/hd_doctest.ex:4: HdDoctest (module)
```
And _some_ message is expected, if you try with:
```elixir
iex> hd([])
** (ArgumentError)
```
Then you get the error:
```
1) doctest module HdDoctest (1) (HdDoctestTest)
test/hd_doctest_test.exs:3
Doctest failed: wrong message for ArgumentError
expected:
""
actual:
"errors were found at the given arguments:\n\n * 1st argument: not a nonempty list\n"
doctest:
iex> hd([])
** (ArgumentError)
stacktrace:
lib/hd_doctest.ex:4: HdDoctest (module)
```