4 ms·
Good example: writing a compiler. I started (but never finished) writing a WASM interpreter in JavaScript. (https://github.com/bgard6977/wasm-int https://github
by voodootrucker 8y ago
Good example: writing a compiler. I started (but never finished) writing a WASM interpreter in JavaScript. (https://github.com/bgard6977/wasm-int https://github.com/bgard6977/wasm-int)
My test suite had simple programs in C, and used emcc to compile and run them, then compare the results from a known-good implementation to the one I was writing.
As I went, I would add one new instruction to the program at a time.
That's a perfect example of outside-in testing, and evolving the requirements, tests, and code simultaneously.
- kazinator 8y agoThe test case programs/expressions input into a compiler are external regression test cases. By itself, that is not TDD. External compiler tests may seem TDD-like because they exist first, and make the compiler fail until the required features are working. TDD is about bogging down the code with internal tests that treat every aspect of the code as a committed feature. You cannot do a single thing that doesn't first fail some newly added test, which then goes green.
- crdoconnor 8y agoI call this "unit test driven development". I find it pretty horrible unless the code is largely algorithmic. ATDD works though.