diff --git a/exercises/wordy/canonical-data.json b/exercises/wordy/canonical-data.json index ab7384c8d7..79b0f66049 100644 --- a/exercises/wordy/canonical-data.json +++ b/exercises/wordy/canonical-data.json @@ -1,6 +1,6 @@ { "exercise": "wordy", - "version": "1.2.0", + "version": "1.3.0", "comments": [ "The tests that expect an 'error' should be implemented to raise", "an error, or indicate a failure. Implement this in a way that", @@ -134,6 +134,46 @@ "question": "Who is the President of the United States?" }, "expected": {"error": "unknown operation"} + }, + { + "description": "reject incomplete problem", + "property": "answer", + "input": { + "question": "What is 1 plus?" + }, + "expected": {"error": "syntax error"} + }, + { + "description": "reject two operations in a row", + "property": "answer", + "input": { + "question": "What is 1 plus plus 2?" + }, + "expected": {"error": "syntax error"} + }, + { + "description": "reject two numbers in a row", + "property": "answer", + "input": { + "question": "What is 1 plus 2 1?" + }, + "expected": {"error": "syntax error"} + }, + { + "description": "reject postfix notation", + "property": "answer", + "input": { + "question": "What is 1 2 plus?" + }, + "expected": {"error": "syntax error"} + }, + { + "description": "reject prefix notation", + "property": "answer", + "input": { + "question": "What is plus 1 2?" + }, + "expected": {"error": "syntax error"} } ] } \ No newline at end of file diff --git a/exercises/wordy/description.md b/exercises/wordy/description.md index 50b9eac5d5..6e97f6f4a4 100644 --- a/exercises/wordy/description.md +++ b/exercises/wordy/description.md @@ -41,6 +41,14 @@ left-to-right, _ignoring the typical order of operations._ 15 (i.e. not 9) +## Iteration 4 — Errors + +The parser should reject: + +* Unsupported operations ("What is 52 cubed?") +* Non-math questions ("Who is the President of the United States") +* Word problems with invalid syntax ("What is 1 plus plus 2?") + ## Bonus — Exponentials If you'd like, handle exponentials.