Collatz Conjecture Test - missing case

The tests run in the Collatz Conjecture exercise only cover integers and zero, so the condition of the input being an integer is not tested. The community submissions and examples of different approaches that I saw wouldn’t return the error message when evaluating a non integer(e.g. a decimal number) as far as it is bigger than 1.

Most exercises here at Exercism focus on valid inputs. Requiring input validation would make the solutions much longer and shift the focus.

Some tracks might implement additional tests that requires some level of input validation, but AFAIK the language-agnostic problem specifications do not require that.

Also, in my experience not every function needs to validate all its parameters and preconditions. That’s typically done at specific places of the code, e.g. where responsibilities change or at module boundaries.

4 Likes

Thank you, I didn’t see it from the pragmatic side of just solving the exercise. Actually I took for granted that the input was a number, but it could also not be.
Same thing happens for sure in more exercises I have done and I just didn’t realize, but in this case I found it weird that nobody added that condition and I checked it.