Comment by flakes
3 months ago
Really loving those markdown style tests. I think it's a really fantastic idea that allows the tests to easily act as documentation too.
Can you explain how you came up with this solution? Rust docs code-examples inspired?
That concept has been formalized as part of the Python standard library.
https://docs.python.org/3/library/doctest.html
Ah very nice! Did not realize this was a part of the standard library!
It's been there since Python v2.1 https://docs.python.org/release/2.1/lib/module-doctest.html
2 replies →
Elixir has this.
https://hexdocs.pm/elixir/main/docs-tests-and-with.html
I use this in my books to show the output but also to "test" that the code found in my books actually works.
I love doctest as it works so well with a REPL but unfortunately it hasn't really gained traction anywhere I've seen.