Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/addErrorObjects' (#1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpottsoh committed Sep 24, 2018
2 parents 349eca2 + aaadbac commit 13da639
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 47 deletions.
38 changes: 19 additions & 19 deletions exercises/forth/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"exercise": "forth",
"version": "1.6.0",
"version": "1.7.0",
"comments": [
"The cases are split into multiple sections, all with the same structure.",
"In all cases, the `expected` key is the resulting stack",
"after executing the Forth program contained in the `input` key."
"after executing the Forth program contained in the `input` key, unless an 'error' exists."
],
"cases": [
{
Expand Down Expand Up @@ -37,15 +37,15 @@
"input": {
"instructions": ["+"]
},
"expected": null
"expected": {"error": "empty stack"}
},
{
"description": "errors if there is only one value on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 +"]
},
"expected": null
"expected": {"error": "only one value on stack"}
}
]
},
Expand All @@ -66,15 +66,15 @@
"input": {
"instructions": ["-"]
},
"expected": null
"expected": {"error": "empty stack"}
},
{
"description": "errors if there is only one value on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 -"]
},
"expected": null
"expected": {"error": "only one value on the stack"}
}
]
},
Expand All @@ -95,15 +95,15 @@
"input": {
"instructions": ["*"]
},
"expected": null
"expected": {"error": "empty stack"}
},
{
"description": "errors if there is only one value on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 *"]
},
"expected": null
"expected": {"error": "only one value on the stack"}
}
]
},
Expand Down Expand Up @@ -132,23 +132,23 @@
"input": {
"instructions": ["4 0 /"]
},
"expected": null
"expected": {"error": "divide by zero"}
},
{
"description": "errors if there is nothing on the stack",
"property": "evaluate",
"input": {
"instructions": ["/"]
},
"expected": null
"expected": {"error": "empty stack"}
},
{
"description": "errors if there is only one value on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 /"]
},
"expected": null
"expected": {"error": "only one value on the stack"}
}
]
},
Expand Down Expand Up @@ -198,7 +198,7 @@
"input": {
"instructions": ["dup"]
},
"expected": null
"expected": {"error": "empty stack"}
}
]
},
Expand Down Expand Up @@ -227,7 +227,7 @@
"input": {
"instructions": ["drop"]
},
"expected": null
"expected": {"error": "empty stack"}
}
]
},
Expand Down Expand Up @@ -256,15 +256,15 @@
"input": {
"instructions": ["swap"]
},
"expected": null
"expected": {"error": "empty stack"}
},
{
"description": "errors if there is only one value on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 swap"]
},
"expected": null
"expected": {"error": "only one value on the stack"}
}
]
},
Expand Down Expand Up @@ -293,15 +293,15 @@
"input": {
"instructions": ["over"]
},
"expected": null
"expected": {"error": "empty stack"}
},
{
"description": "errors if there is only one value on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 over"]
},
"expected": null
"expected": {"error": "only one value on the stack stack"}
}
]
},
Expand Down Expand Up @@ -395,15 +395,15 @@
"input": {
"instructions": [": 1 2 ;"]
},
"expected": null
"expected": {"error": "illegal operation"}
},
{
"description": "errors if executing a non-existent word",
"property": "evaluate",
"input": {
"instructions": ["foo"]
},
"expected": null
"expected": {"error": "undefined operation"}
}
]
},
Expand Down
30 changes: 15 additions & 15 deletions exercises/phone-number/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"exercise": "phone-number",
"version": "1.5.0",
"version": "1.6.0",
"cases": [
{
"description": "Cleanup user-entered phone numbers",
"comments": [
" Returns the cleaned phone number if given number is valid, "
, " else returns nil. Note that number is not formatted, "
, " else returns error object. Note that number is not formatted,"
, " just a 10-digit number is returned. "
],
"cases": [
Expand Down Expand Up @@ -40,15 +40,15 @@
"input": {
"phrase": "123456789"
},
"expected": null
"expected": {"error": "incorrect number of digits"}
},
{
"description": "invalid when 11 digits does not start with a 1",
"property": "clean",
"input": {
"phrase": "22234567890"
},
"expected": null
"expected": {"error": "11 digits must start with 1"}
},
{
"description": "valid when 11 digits and starting with 1",
Expand All @@ -72,87 +72,87 @@
"input": {
"phrase": "321234567890"
},
"expected": null
"expected": {"error": "more than 11 digits"}
},
{
"description": "invalid with letters",
"property": "clean",
"input": {
"phrase": "123-abc-7890"
},
"expected": null
"expected": {"error": "alphanumerics not permitted"}
},
{
"description": "invalid with punctuations",
"property": "clean",
"input": {
"phrase": "123-@:!-7890"
},
"expected": null
"expected": {"error": "punctuations not permitted"}
},
{
"description": "invalid if area code starts with 0",
"property": "clean",
"input": {
"phrase": "(023) 456-7890"
},
"expected": null
"expected": {"error": "area code cannot start with zero"}
},
{
"description": "invalid if area code starts with 1",
"property": "clean",
"input": {
"phrase": "(123) 456-7890"
},
"expected": null
"expected": {"error": "area code cannot start with one"}
},
{
"description": "invalid if exchange code starts with 0",
"property": "clean",
"input": {
"phrase": "(223) 056-7890"
},
"expected": null
"expected": {"error": "exchange cannot start with zero"}
},
{
"description": "invalid if exchange code starts with 1",
"property": "clean",
"input": {
"phrase": "(223) 156-7890"
},
"expected": null
"expected": {"error": "exchange cannot start with one"}
},
{
"description": "invalid if area code starts with 0 on valid 11-digit number",
"property": "clean",
"input": {
"phrase": "1 (023) 456-7890"
},
"expected": null
"expected": {"error": "area code cannot start with zero"}
},
{
"description": "invalid if area code starts with 1 on valid 11-digit number",
"property": "clean",
"input": {
"phrase": "1 (123) 456-7890"
},
"expected": null
"expected": {"error": "area code cannot start with one"}
},
{
"description": "invalid if exchange code starts with 0 on valid 11-digit number",
"property": "clean",
"input": {
"phrase": "1 (223) 056-7890"
},
"expected": null
"expected": {"error": "exchange code cannot start with zero"}
},
{
"description": "invalid if exchange code starts with 1 on valid 11-digit number",
"property": "clean",
"input": {
"phrase": "1 (223) 156-7890"
},
"expected": null
"expected": {"error": "exchange code cannot start with one"}
}
]
}
Expand Down
12 changes: 6 additions & 6 deletions exercises/queen-attack/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"exercise": "queen-attack",
"version": "2.1.0",
"version": "2.2.0",
"comments": [
"Testing invalid positions will vary by language. The expected",
"value of -1 is there to indicate some sort of failure should",
"value of 'error' is there to indicate some sort of failure should",
"occur, while a 0 means no failure.",
"Some languages implement tests beyond this set, such as checking",
"for two pieces being placed on the same position, representing",
Expand Down Expand Up @@ -38,7 +38,7 @@
}
}
},
"expected": -1
"expected": {"error": "row not positive"}
},
{
"description": "queen must have row on board",
Expand All @@ -51,7 +51,7 @@
}
}
},
"expected": -1
"expected": {"error": "row not on board"}
},
{
"description": "queen must have positive column",
Expand All @@ -64,7 +64,7 @@
}
}
},
"expected": -1
"expected": {"error": "column not positive"}
},
{
"description": "queen must have column on board",
Expand All @@ -77,7 +77,7 @@
}
}
},
"expected": -1
"expected": {"error": "column not on board"}
}
]
},
Expand Down
8 changes: 4 additions & 4 deletions exercises/say/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"exercise": "say",
"version": "1.1.0",
"version": "1.2.0",
"comments": [
"Here -1 is used as expected value to indicate that the",
"An 'error' object is used as expected value to indicate that the",
"input value is out of the range described in the exercise."
],
"cases": [
Expand Down Expand Up @@ -116,15 +116,15 @@
"input": {
"number": -1
},
"expected": -1
"expected": {"error": "input out of range"}
},
{
"description": "numbers above 999,999,999,999 are out of range",
"property": "say",
"input": {
"number": 1000000000000
},
"expected": -1
"expected": {"error": "input out of range"}
}
]
}
Loading

0 comments on commit 13da639

Please sign in to comment.