News for hackers. Stuff that matters.
Re:Save the code or save the tests? (2020) by cronin101 on Wednesday June 09, 2021 @06:11PM (#27453961)

    Forall A:
    add(A, 0) == A

    Forall A B C:
    add(add(A,B), C) == add(A, add(B, C))
I think that’s sufficient. Rule 101 of useful testing is understanding the actual constraints you rely on.

Maybe throw in add(A, B) == add(B, A) if you’re angling for a promotion…

Re:Save the code or save the tests? (2020) by postalrat on Wednesday June 09, 2021 @08:05PM (#27455061)

    add(a, b) => a == 1 && b == 1 ? 1 : a + b
Kinda disappointing your test would take so long to run and still catch a simple error.
Re:Save the code or save the tests? (2020) by milkey_mouse on Wednesday June 09, 2021 @10:51PM (#27456167)
> your test would take so long to run

I think GP's test would probably be implemented with property testing (or even better, symbolic execution). It wouldn't necessarily take super long to run.

Re:Save the code or save the tests? (2020) by postalrat on Wednesday June 09, 2021 @11:28PM (#27456357)
How difficult would it be to write a proper test with one of those systems for something more complex when even this trivial example doesn't have solution yet?