Skip to content

Commit dcc052c

Browse files
authored
Updtated tests for Forth from problem specs. (exercism#3814)
1 parent d7a8e5b commit dcc052c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

exercises/practice/forth/.meta/tests.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ description = "addition -> errors if there is nothing on the stack"
2424
[06efb9a4-817a-435e-b509-06166993c1b8]
2525
description = "addition -> errors if there is only one value on the stack"
2626

27+
[1e07a098-c5fa-4c66-97b2-3c81205dbc2f]
28+
description = "addition -> more than two values on the stack"
29+
2730
[09687c99-7bbc-44af-8526-e402f997ccbf]
2831
description = "subtraction -> can subtract two numbers"
2932

@@ -33,6 +36,9 @@ description = "subtraction -> errors if there is nothing on the stack"
3336
[b3cee1b2-9159-418a-b00d-a1bb3765c23b]
3437
description = "subtraction -> errors if there is only one value on the stack"
3538

39+
[2c8cc5ed-da97-4cb1-8b98-fa7b526644f4]
40+
description = "subtraction -> more than two values on the stack"
41+
3642
[5df0ceb5-922e-401f-974d-8287427dbf21]
3743
description = "multiplication -> can multiply two numbers"
3844

@@ -42,6 +48,9 @@ description = "multiplication -> errors if there is nothing on the stack"
4248
[8ba4b432-9f94-41e0-8fae-3b3712bd51b3]
4349
description = "multiplication -> errors if there is only one value on the stack"
4450

51+
[5cd085b5-deb1-43cc-9c17-6b1c38bc9970]
52+
description = "multiplication -> more than two values on the stack"
53+
4554
[e74c2204-b057-4cff-9aa9-31c7c97a93f5]
4655
description = "division -> can divide two numbers"
4756

@@ -57,12 +66,21 @@ description = "division -> errors if there is nothing on the stack"
5766
[d5547f43-c2ff-4d5c-9cb0-2a4f6684c20d]
5867
description = "division -> errors if there is only one value on the stack"
5968

69+
[f224f3e0-b6b6-4864-81de-9769ecefa03f]
70+
description = "division -> more than two values on the stack"
71+
6072
[ee28d729-6692-4a30-b9be-0d830c52a68c]
6173
description = "combined arithmetic -> addition and subtraction"
6274

6375
[40b197da-fa4b-4aca-a50b-f000d19422c1]
6476
description = "combined arithmetic -> multiplication and division"
6577

78+
[f749b540-53aa-458e-87ec-a70797eddbcb]
79+
description = "combined arithmetic -> multiplication and addition"
80+
81+
[c8e5a4c2-f9bf-4805-9a35-3c3314e4989a]
82+
description = "combined arithmetic -> addition and multiplication"
83+
6684
[c5758235-6eef-4bf6-ab62-c878e50b9957]
6785
description = "dup -> copies a value on the stack"
6886

exercises/practice/forth/forth_test.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# These tests are auto-generated with test data from:
22
# https://github.com/exercism/problem-specifications/tree/main/exercises/forth/canonical-data.json
3-
# File last updated on 2023-07-19
3+
# File last updated on 2024-11-04
44

55
import unittest
66

@@ -36,6 +36,9 @@ def test_addition_errors_if_there_is_only_one_value_on_the_stack(self):
3636
str(err.exception.args[0]), "Insufficient number of items in stack"
3737
)
3838

39+
def test_addition_more_than_two_values_on_the_stack(self):
40+
self.assertEqual(evaluate(["1 2 3 +"]), [1, 5])
41+
3942
def test_subtraction_can_subtract_two_numbers(self):
4043
self.assertEqual(evaluate(["3 4 -"]), [-1])
4144

@@ -55,6 +58,9 @@ def test_subtraction_errors_if_there_is_only_one_value_on_the_stack(self):
5558
str(err.exception.args[0]), "Insufficient number of items in stack"
5659
)
5760

61+
def test_subtraction_more_than_two_values_on_the_stack(self):
62+
self.assertEqual(evaluate(["1 12 3 -"]), [1, 9])
63+
5864
def test_multiplication_can_multiply_two_numbers(self):
5965
self.assertEqual(evaluate(["2 4 *"]), [8])
6066

@@ -74,6 +80,9 @@ def test_multiplication_errors_if_there_is_only_one_value_on_the_stack(self):
7480
str(err.exception.args[0]), "Insufficient number of items in stack"
7581
)
7682

83+
def test_multiplication_more_than_two_values_on_the_stack(self):
84+
self.assertEqual(evaluate(["1 2 3 *"]), [1, 6])
85+
7786
def test_division_can_divide_two_numbers(self):
7887
self.assertEqual(evaluate(["12 3 /"]), [4])
7988

@@ -103,12 +112,21 @@ def test_division_errors_if_there_is_only_one_value_on_the_stack(self):
103112
str(err.exception.args[0]), "Insufficient number of items in stack"
104113
)
105114

115+
def test_division_more_than_two_values_on_the_stack(self):
116+
self.assertEqual(evaluate(["1 12 3 /"]), [1, 4])
117+
106118
def test_combined_arithmetic_addition_and_subtraction(self):
107119
self.assertEqual(evaluate(["1 2 + 4 -"]), [-1])
108120

109121
def test_combined_arithmetic_multiplication_and_division(self):
110122
self.assertEqual(evaluate(["2 4 * 3 /"]), [2])
111123

124+
def test_combined_arithmetic_multiplication_and_addition(self):
125+
self.assertEqual(evaluate(["1 3 4 * +"]), [13])
126+
127+
def test_combined_arithmetic_addition_and_multiplication(self):
128+
self.assertEqual(evaluate(["1 3 4 + *"]), [7])
129+
112130
def test_dup_copies_a_value_on_the_stack(self):
113131
self.assertEqual(evaluate(["1 dup"]), [1, 1])
114132

0 commit comments

Comments
 (0)