Skip to content

Commit

Permalink
Forth: additional tests for "combined arithmetic" category (#2477)
Browse files Browse the repository at this point in the history
* Forth: additional tests for "combined arithmetic" category
This will ensure that students are popping numbers off the correct end of the stack (for languages without a builtin Stack type).

* with UUIDs for the new tests

* add arithmetic tests for "more than two values on the stack"
  • Loading branch information
glennj authored Oct 4, 2024
1 parent a07de06 commit 4b91a92
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions exercises/forth/canonical-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@
"expected": {
"error": "only one value on the stack"
}
},
{
"uuid": "1e07a098-c5fa-4c66-97b2-3c81205dbc2f",
"description": "more than two values on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 2 3 +"]
},
"expected": [1, 5]
}
]
},
Expand Down Expand Up @@ -98,6 +107,15 @@
"expected": {
"error": "only one value on the stack"
}
},
{
"uuid": "2c8cc5ed-da97-4cb1-8b98-fa7b526644f4",
"description": "more than two values on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 12 3 -"]
},
"expected": [1, 9]
}
]
},
Expand Down Expand Up @@ -134,6 +152,15 @@
"expected": {
"error": "only one value on the stack"
}
},
{
"uuid": "5cd085b5-deb1-43cc-9c17-6b1c38bc9970",
"description": "more than two values on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 2 3 *"]
},
"expected": [1, 6]
}
]
},
Expand Down Expand Up @@ -190,6 +217,15 @@
"expected": {
"error": "only one value on the stack"
}
},
{
"uuid": "f224f3e0-b6b6-4864-81de-9769ecefa03f",
"description": "more than two values on the stack",
"property": "evaluate",
"input": {
"instructions": ["1 12 3 /"]
},
"expected": [1, 4]
}
]
},
Expand All @@ -213,6 +249,24 @@
"instructions": ["2 4 * 3 /"]
},
"expected": [2]
},
{
"uuid": "f749b540-53aa-458e-87ec-a70797eddbcb",
"description": "multiplication and addition",
"property": "evaluate",
"input": {
"instructions": ["1 3 4 * +"]
},
"expected": [13]
},
{
"uuid": "c8e5a4c2-f9bf-4805-9a35-3c3314e4989a",
"description": "addition and multiplication",
"property": "evaluate",
"input": {
"instructions": ["1 3 4 + *"]
},
"expected": [7]
}
]
},
Expand Down

0 comments on commit 4b91a92

Please sign in to comment.