Hi there, I was just mentoring on the Python track with the problem wordy and found a couple of issues in the users code that still passed test cases, I will give some examples below.
if char in operations or char.isdigit() or char.startswith("-")
The test case containing something like -five does not exist. Given this users code it would then continue to try and use it as an operand of the problem. They had clearly intended it to cover numbers like -5, I believe a test case should be added to cover this kind of solution.
If you agree I would be more than happy to create a PR for you to have a look at.
It’s unclear to me what the specific syntax error is in that test case. No other test cases use either spelled-out words or - in front of an invalid number. So which one are we testing?
I think something like "What is 5 plus -foo?" or "What is 5 plus -?" conveys our intent that a - won’t always precede a valid number. That makes the syntax error more apparent.
Along the lines of what we’re trying to test, is this an interesting case to test or a quirk of a specific implementation that this might catch? The tests should guide people to the correct implementation and help ensure the implementation is correct. At the same time, the tests aren’t meant to be exhaustive and catch every implementation that can be broken but a targeted test case.
Is this a reasonable input that should be tested for or a reaction to a very specific implementation that would fall into “exhaustive testing”?
@BNAndras - I agree it could be worth changing my example test case as that is true and it makes it more clear what it is.
@IsaacG - I would say so, in the problem it is made clear to check for negative numbers but a rudimentary approach would just check if a word in a string starts with a - sign before running it currently this will pass because no test cases will stop it. This test case will prevent that solution so they must check that the remainder of the word is a valid digit.