3 ms·
Elixir has a similar concept with doc tests: https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html https://elixir-lang.org/getting-started/m
by mabbo 3y ago
Elixir has a similar concept with doc tests:
https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html https://elixir-lang.org/getting-started/mix-otp/docs-tests-a...
You're comments/docs for the method can have demonstration code that is executed when you run your tests, ensuring your docs remain accurate.
It's a great pattern.
- xrd 3y agoI came here to say this and you beat me to it! Love this part of elixir. It's a good way to think about your functions: if you can't write a doc test, you've probably written a function with side effects.
- mattkrause 3y agoJulia (Documenter.jl), Python (doctest) and R have (doctest) them too.
- otherme123 3y agoNim: runnableExamples.
- nazka 3y agoIs it similar to what Rust does?