Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/axelson/multiline_doctest_repro


https://github.com/axelson/multiline_doctest_repro

Last synced: about 1 month ago
JSON representation

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)
```