3 ms·
static typing doesn't cover all (or most) testing but it absolutely replaces type testing. webdev isn't square root functions it's working with complex data AP
by mmcromp 2y ago
static typing doesn't cover all (or most) testing but it absolutely replaces type testing.
webdev isn't square root functions it's working with complex data APIs.
In fact, the argument was about ruby/rails not needing types/interfaces was because "the tests are the interface" that's how baked in tdd was
- kazinator 2y agoIf I have a dynamically typed add function and I test that add(2, 2) produces 4, then the type testing is rolled right into it trivially. 4 has a type. If an object comes out of add(2, 2) that isn't an integer, then it won't match 4. Oftentimes, type is just a less specific match. It would be a waste of time to write a separate test case that add(2, 2) produces an integer, rather than just testing that it produces 4. I've hardly ever seen Lisp test cases that look only at the type of an output, rather than a specific value. Even a function whose job is to operate on types actually has inputs and outputs that are values representing types; e.g. the symbol string representing string types or whatever. However, there are tests which show that a function signals an error when given wrong types. Those would not be necessary in a static language; the function called with wrong types would not compile, and it goes without saying that all tests must compile, unless we are testing the compiler.