Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Really good answer! But one thing that still bothers me is checking the return. in the sqrt(x) example it should always be equal or above 0. But say that it isn't, then it is a programming error and most likely an edge case that should be added to the test suite. I think what I am after is that when it comes to programming errors you should fail in the test stage, not in runtime or worse, in production Commented Jun 3, 2019 at 10:28
  • 1
    @munHunger thanks :) i added a paragrah to address you question. It boils down to this: you should have tests that test your function thoroughly. But even with 100% coverage you may not catch all the cases. And a contract violation is something far more fundamental than a failed unit tests. If your sqrt(2) is -1 something is for 100% sure off. Going on from this point will not lead to anything good (other than avoiding an error message) Commented Jun 3, 2019 at 11:54