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
55import 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