4 ms·
That Racket module functionality where you can add unit tests right with your code ("module+"), but will get stripped when compiled - that thing is quite magica
by i_feel_great 9y ago
That Racket module functionality where you can add unit tests right with your code ("module+"), but will get stripped when compiled - that thing is quite magical. Is there another system that has this?
- thescribe 9y agoI don't think it is an official part of the language but the Pragmatic Programmers Elixir book does this in one of their examples code sections.
- bglusman 9y agoIt is an official part of the language, and is automatically part of the compiled docs, which are also an official part of the language! https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html#doctests https://elixir-lang.org/getting-started/mix-otp/docs-tests-a...
- deckiedan 9y agoRust. https://doc.rust-lang.org/book/second-edition/ch11-03-test-organization.html https://doc.rust-lang.org/book/second-edition/ch11-03-test-o...
- bglusman 9y agoFrom thescribe's parallel comment it sounds like you're describing doctests which is a built in feature in Elixir, and I believe in Python also. Many languages have doctest libraries available, though not many support it being part of canonical documentation... I've been meaning to try the ruby-rspec doctest library https://github.com/doctest/doctest-rspec https://github.com/doctest/doctest-rspec though there's several others besides that one
- zem 9y agohttps://dlang.org/spec/unittest.html https://dlang.org/spec/unittest.html for D