4 ms·
I understand the code from the article is contrived, but I feel it serves as a bad example. Presumably you would write unit tests for such code in any language,
by kilink 12y ago
I understand the code from the article is contrived, but I feel it serves as a bad example. Presumably you would write unit tests for such code in any language, regardless of type safety. Such tests would catch errors like this.
> Tests that wouldn’t tell you very much at all in Scala (that just run the code and don’t check the result) suddenly become incredibly useful!
I don't really know what that means. A Python programmer doesn't (shouldn't?) go out of their way to write insane tests like this because they are scared of the "uncertainty" of dynamic typing. Just write unit tests, and make sure your code is sufficiently covered. Use flakes/frosted to find low hanging fruit like this.
- acveilleux 12y agoOn the other hand, I see a lot of Java code where the unit tests are woefully inadequate but the fact that Eclipse/IntelliJ/Whatever had no warnings and javac liked the code meant the programmer thought he'd done a good job. Hell, most of the world's C code was written basically that way. Often with a lot less testing and most of the testing that was actually done included no edge cases.
- codygman 12y agoIn Haskell I wouldn't write a test to verify that it's already guaranteed.
- codygman 12y agoIn Haskell I wouldn't write a test to verify a type that is already guaranteed.