============================= test session starts ==============================
platform linux -- Python 3.11.17, pytest-9.0.2, pluggy-1.6.0
rootdir: forth
plugins: env-1.6.0, cov-7.0.0, anyio-4.12.1
collected 54 items
forth_test.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%]
=================================== FAILURES ===================================
_________________ ForthTest.test_addition_can_add_two_numbers __________________
self = <forth_test.ForthTest testMethod=test_addition_can_add_two_numbers>
code Copy code
def test_addition_can_add_two_numbers(self):
code Copy code
self.assertEqual(evaluate(["1 2 +"]), [3])
code Copy code
^^^^^^^^^^^^^^^^^^^
forth_test.py:21:
input_data = ['1 2 +']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_______ ForthTest.test_addition_errors_if_there_is_nothing_on_the_stack ________
self = <forth_test.ForthTest testMethod=test_addition_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_addition_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["+"])
forth_test.py:25:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
____ ForthTest.test_addition_errors_if_there_is_only_one_value_on_the_stack ____
self = <forth_test.ForthTest testMethod=test_addition_errors_if_there_is_only_one_value_on_the_stack>
code Copy code
def test_addition_errors_if_there_is_only_one_value_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["1 +"])
forth_test.py:33:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__________ ForthTest.test_addition_more_than_two_values_on_the_stack ___________
self = <forth_test.ForthTest testMethod=test_addition_more_than_two_values_on_the_stack>
code Copy code
def test_addition_more_than_two_values_on_the_stack(self):
code Copy code
self.assertEqual(evaluate(["1 2 3 +"]), [1, 5])
code Copy code
^^^^^^^^^^^^^^^^^^^^^
forth_test.py:40:
input_data = ['1 2 3 +']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______ ForthTest.test_case_insensitivity_definitions_are_case_insensitive ______
self = <forth_test.ForthTest testMethod=test_case_insensitivity_definitions_are_case_insensitive>
code Copy code
def test_case_insensitivity_definitions_are_case_insensitive(self):
code Copy code
self.assertEqual(evaluate([": SWAP DUP Dup dup ;", "1 swap"]), [1, 1, 1, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:263:
input_data = [': SWAP DUP Dup dup ;', '1 swap']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__________ ForthTest.test_case_insensitivity_drop_is_case_insensitive __________
self = <forth_test.ForthTest testMethod=test_case_insensitivity_drop_is_case_insensitive>
code Copy code
def test_case_insensitivity_drop_is_case_insensitive(self):
code Copy code
self.assertEqual(evaluate(["1 2 3 4 DROP Drop drop"]), [1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:251:
input_data = ['1 2 3 4 DROP Drop drop']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__________ ForthTest.test_case_insensitivity_dup_is_case_insensitive ___________
self = <forth_test.ForthTest testMethod=test_case_insensitivity_dup_is_case_insensitive>
code Copy code
def test_case_insensitivity_dup_is_case_insensitive(self):
code Copy code
self.assertEqual(evaluate(["1 DUP Dup dup"]), [1, 1, 1, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:248:
input_data = ['1 DUP Dup dup']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__________ ForthTest.test_case_insensitivity_over_is_case_insensitive __________
self = <forth_test.ForthTest testMethod=test_case_insensitivity_over_is_case_insensitive>
code Copy code
def test_case_insensitivity_over_is_case_insensitive(self):
code Copy code
self.assertEqual(evaluate(["1 2 OVER Over over"]), [1, 2, 1, 2, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:257:
input_data = ['1 2 OVER Over over']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__________ ForthTest.test_case_insensitivity_swap_is_case_insensitive __________
self = <forth_test.ForthTest testMethod=test_case_insensitivity_swap_is_case_insensitive>
code Copy code
def test_case_insensitivity_swap_is_case_insensitive(self):
code Copy code
self.assertEqual(evaluate(["1 2 SWAP 3 Swap 4 swap"]), [2, 3, 4, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:254:
input_data = ['1 2 SWAP 3 Swap 4 swap']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__ ForthTest.test_case_insensitivity_user_defined_words_are_case_insensitive ___
self = <forth_test.ForthTest testMethod=test_case_insensitivity_user_defined_words_are_case_insensitive>
code Copy code
def test_case_insensitivity_user_defined_words_are_case_insensitive(self):
code Copy code
self.assertEqual(evaluate([": foo dup ;", "1 FOO Foo foo"]), [1, 1, 1, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:260:
input_data = [': foo dup ;', '1 FOO Foo foo']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
________ ForthTest.test_combined_arithmetic_addition_and_multiplication ________
self = <forth_test.ForthTest testMethod=test_combined_arithmetic_addition_and_multiplication>
code Copy code
def test_combined_arithmetic_addition_and_multiplication(self):
code Copy code
self.assertEqual(evaluate(["1 3 4 + *"]), [7])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:128:
input_data = ['1 3 4 + *']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_________ ForthTest.test_combined_arithmetic_addition_and_subtraction __________
self = <forth_test.ForthTest testMethod=test_combined_arithmetic_addition_and_subtraction>
code Copy code
def test_combined_arithmetic_addition_and_subtraction(self):
code Copy code
self.assertEqual(evaluate(["1 2 + 4 -"]), [-1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:119:
input_data = ['1 2 + 4 -']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
________ ForthTest.test_combined_arithmetic_multiplication_and_addition ________
self = <forth_test.ForthTest testMethod=test_combined_arithmetic_multiplication_and_addition>
code Copy code
def test_combined_arithmetic_multiplication_and_addition(self):
code Copy code
self.assertEqual(evaluate(["1 3 4 * +"]), [13])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:125:
input_data = ['1 3 4 * +']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
________ ForthTest.test_combined_arithmetic_multiplication_and_division ________
self = <forth_test.ForthTest testMethod=test_combined_arithmetic_multiplication_and_division>
code Copy code
def test_combined_arithmetic_multiplication_and_division(self):
code Copy code
self.assertEqual(evaluate(["2 4 * 3 /"]), [2])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:122:
input_data = ['2 4 * 3 /']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
________________ ForthTest.test_division_can_divide_two_numbers ________________
self = <forth_test.ForthTest testMethod=test_division_can_divide_two_numbers>
code Copy code
def test_division_can_divide_two_numbers(self):
code Copy code
self.assertEqual(evaluate(["12 3 /"]), [4])
code Copy code
^^^^^^^^^^^^^^^^^^^^
forth_test.py:87:
input_data = ['12 3 /']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______________ ForthTest.test_division_errors_if_dividing_by_zero ______________
self = <forth_test.ForthTest testMethod=test_division_errors_if_dividing_by_zero>
code Copy code
def test_division_errors_if_dividing_by_zero(self):
# divide by zero
with self.assertRaises(ZeroDivisionError) as err:
code Copy code
evaluate(["4 0 /"])
forth_test.py:95:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_______ ForthTest.test_division_errors_if_there_is_nothing_on_the_stack ________
self = <forth_test.ForthTest testMethod=test_division_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_division_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["/"])
forth_test.py:101:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
____ ForthTest.test_division_errors_if_there_is_only_one_value_on_the_stack ____
self = <forth_test.ForthTest testMethod=test_division_errors_if_there_is_only_one_value_on_the_stack>
code Copy code
def test_division_errors_if_there_is_only_one_value_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["1 /"])
forth_test.py:109:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__________ ForthTest.test_division_more_than_two_values_on_the_stack ___________
self = <forth_test.ForthTest testMethod=test_division_more_than_two_values_on_the_stack>
code Copy code
def test_division_more_than_two_values_on_the_stack(self):
code Copy code
self.assertEqual(evaluate(["1 12 3 /"]), [1, 4])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:116:
input_data = ['1 12 3 /']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______________ ForthTest.test_division_performs_integer_division _______________
self = <forth_test.ForthTest testMethod=test_division_performs_integer_division>
code Copy code
def test_division_performs_integer_division(self):
code Copy code
self.assertEqual(evaluate(["8 3 /"]), [2])
code Copy code
^^^^^^^^^^^^^^^^^^^
forth_test.py:90:
input_data = ['8 3 /']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_________ ForthTest.test_drop_errors_if_there_is_nothing_on_the_stack __________
self = <forth_test.ForthTest testMethod=test_drop_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_drop_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["drop"])
forth_test.py:152:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_ ForthTest.test_drop_removes_the_top_value_on_the_stack_if_it_is_not_the_only_one _
self = <forth_test.ForthTest testMethod=test_drop_removes_the_top_value_on_the_stack_if_it_is_not_the_only_one>
code Copy code
def test_drop_removes_the_top_value_on_the_stack_if_it_is_not_the_only_one(self):
code Copy code
self.assertEqual(evaluate(["1 2 drop"]), [1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:148:
input_data = ['1 2 drop']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_ ForthTest.test_drop_removes_the_top_value_on_the_stack_if_it_is_the_only_one _
self = <forth_test.ForthTest testMethod=test_drop_removes_the_top_value_on_the_stack_if_it_is_the_only_one>
code Copy code
def test_drop_removes_the_top_value_on_the_stack_if_it_is_the_only_one(self):
code Copy code
self.assertEqual(evaluate(["1 drop"]), [])
code Copy code
^^^^^^^^^^^^^^^^^^^^
forth_test.py:145:
input_data = ['1 drop']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
________________ ForthTest.test_dup_copies_a_value_on_the_stack ________________
self = <forth_test.ForthTest testMethod=test_dup_copies_a_value_on_the_stack>
code Copy code
def test_dup_copies_a_value_on_the_stack(self):
code Copy code
self.assertEqual(evaluate(["1 dup"]), [1, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^
forth_test.py:131:
input_data = ['1 dup']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_____________ ForthTest.test_dup_copies_the_top_value_on_the_stack _____________
self = <forth_test.ForthTest testMethod=test_dup_copies_the_top_value_on_the_stack>
code Copy code
def test_dup_copies_the_top_value_on_the_stack(self):
code Copy code
self.assertEqual(evaluate(["1 2 dup"]), [1, 2, 2])
code Copy code
^^^^^^^^^^^^^^^^^^^^^
forth_test.py:134:
input_data = ['1 2 dup']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__________ ForthTest.test_dup_errors_if_there_is_nothing_on_the_stack __________
self = <forth_test.ForthTest testMethod=test_dup_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_dup_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["dup"])
forth_test.py:138:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
____________ ForthTest.test_multiplication_can_multiply_two_numbers ____________
self = <forth_test.ForthTest testMethod=test_multiplication_can_multiply_two_numbers>
code Copy code
def test_multiplication_can_multiply_two_numbers(self):
code Copy code
self.assertEqual(evaluate(["2 4 *"]), [8])
code Copy code
^^^^^^^^^^^^^^^^^^^
forth_test.py:65:
input_data = ['2 4 *']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
____ ForthTest.test_multiplication_errors_if_there_is_nothing_on_the_stack _____
self = <forth_test.ForthTest testMethod=test_multiplication_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_multiplication_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["*"])
forth_test.py:69:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_ ForthTest.test_multiplication_errors_if_there_is_only_one_value_on_the_stack _
self = <forth_test.ForthTest testMethod=test_multiplication_errors_if_there_is_only_one_value_on_the_stack>
code Copy code
def test_multiplication_errors_if_there_is_only_one_value_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["1 *"])
forth_test.py:77:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_______ ForthTest.test_multiplication_more_than_two_values_on_the_stack ________
self = <forth_test.ForthTest testMethod=test_multiplication_more_than_two_values_on_the_stack>
code Copy code
def test_multiplication_more_than_two_values_on_the_stack(self):
code Copy code
self.assertEqual(evaluate(["1 2 3 *"]), [1, 6])
code Copy code
^^^^^^^^^^^^^^^^^^^^^
forth_test.py:84:
input_data = ['1 2 3 *']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
___ ForthTest.test_over_copies_the_second_element_if_there_are_more_than_two ___
self = <forth_test.ForthTest testMethod=test_over_copies_the_second_element_if_there_are_more_than_two>
code Copy code
def test_over_copies_the_second_element_if_there_are_more_than_two(self):
code Copy code
self.assertEqual(evaluate(["1 2 3 over"]), [1, 2, 3, 2])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:186:
input_data = ['1 2 3 over']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_____ ForthTest.test_over_copies_the_second_element_if_there_are_only_two ______
self = <forth_test.ForthTest testMethod=test_over_copies_the_second_element_if_there_are_only_two>
code Copy code
def test_over_copies_the_second_element_if_there_are_only_two(self):
code Copy code
self.assertEqual(evaluate(["1 2 over"]), [1, 2, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:183:
input_data = ['1 2 over']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_________ ForthTest.test_over_errors_if_there_is_nothing_on_the_stack __________
self = <forth_test.ForthTest testMethod=test_over_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_over_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["over"])
forth_test.py:190:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______ ForthTest.test_over_errors_if_there_is_only_one_value_on_the_stack ______
self = <forth_test.ForthTest testMethod=test_over_errors_if_there_is_only_one_value_on_the_stack>
code Copy code
def test_over_errors_if_there_is_only_one_value_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["1 over"])
forth_test.py:198:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__ ForthTest.test_parsing_and_numbers_numbers_just_get_pushed_onto_the_stack ___
self = <forth_test.ForthTest testMethod=test_parsing_and_numbers_numbers_just_get_pushed_onto_the_stack>
code Copy code
def test_parsing_and_numbers_numbers_just_get_pushed_onto_the_stack(self):
code Copy code
self.assertEqual(evaluate(["1 2 3 4 5"]), [1, 2, 3, 4, 5])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:15:
input_data = ['1 2 3 4 5']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__ ForthTest.test_parsing_and_numbers_pushes_negative_numbers_onto_the_stack ___
self = <forth_test.ForthTest testMethod=test_parsing_and_numbers_pushes_negative_numbers_onto_the_stack>
code Copy code
def test_parsing_and_numbers_pushes_negative_numbers_onto_the_stack(self):
code Copy code
self.assertEqual(evaluate(["-1 -2 -3 -4 -5"]), [-1, -2, -3, -4, -5])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:18:
input_data = ['-1 -2 -3 -4 -5']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_____________ ForthTest.test_subtraction_can_subtract_two_numbers ______________
self = <forth_test.ForthTest testMethod=test_subtraction_can_subtract_two_numbers>
code Copy code
def test_subtraction_can_subtract_two_numbers(self):
code Copy code
self.assertEqual(evaluate(["3 4 -"]), [-1])
code Copy code
^^^^^^^^^^^^^^^^^^^
forth_test.py:43:
input_data = ['3 4 -']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______ ForthTest.test_subtraction_errors_if_there_is_nothing_on_the_stack ______
self = <forth_test.ForthTest testMethod=test_subtraction_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_subtraction_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["-"])
forth_test.py:47:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__ ForthTest.test_subtraction_errors_if_there_is_only_one_value_on_the_stack ___
self = <forth_test.ForthTest testMethod=test_subtraction_errors_if_there_is_only_one_value_on_the_stack>
code Copy code
def test_subtraction_errors_if_there_is_only_one_value_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["1 -"])
forth_test.py:55:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_________ ForthTest.test_subtraction_more_than_two_values_on_the_stack _________
self = <forth_test.ForthTest testMethod=test_subtraction_more_than_two_values_on_the_stack>
code Copy code
def test_subtraction_more_than_two_values_on_the_stack(self):
code Copy code
self.assertEqual(evaluate(["1 12 3 -"]), [1, 9])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:62:
input_data = ['1 12 3 -']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_________ ForthTest.test_swap_errors_if_there_is_nothing_on_the_stack __________
self = <forth_test.ForthTest testMethod=test_swap_errors_if_there_is_nothing_on_the_stack>
code Copy code
def test_swap_errors_if_there_is_nothing_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["swap"])
forth_test.py:168:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______ ForthTest.test_swap_errors_if_there_is_only_one_value_on_the_stack ______
self = <forth_test.ForthTest testMethod=test_swap_errors_if_there_is_only_one_value_on_the_stack>
code Copy code
def test_swap_errors_if_there_is_only_one_value_on_the_stack(self):
with self.assertRaises(StackUnderflowError) as err:
code Copy code
evaluate(["1 swap"])
forth_test.py:176:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_ ForthTest.test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_not_the_only_ones _
self = <forth_test.ForthTest testMethod=test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_not_the_only_ones>
code Copy code
def test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_not_the_only_ones(
self,
):
code Copy code
self.assertEqual(evaluate(["1 2 3 swap"]), [1, 3, 2])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:164:
input_data = ['1 2 3 swap']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_ ForthTest.test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_the_only_ones _
self = <forth_test.ForthTest testMethod=test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_the_only_ones>
code Copy code
def test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_the_only_ones(self):
code Copy code
self.assertEqual(evaluate(["1 2 swap"]), [2, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:159:
input_data = ['1 2 swap']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_______ ForthTest.test_user_defined_words_can_consist_of_built_in_words ________
self = <forth_test.ForthTest testMethod=test_user_defined_words_can_consist_of_built_in_words>
code Copy code
def test_user_defined_words_can_consist_of_built_in_words(self):
code Copy code
self.assertEqual(evaluate([": dup-twice dup dup ;", "1 dup-twice"]), [1, 1, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:205:
input_data = [': dup-twice dup dup ;', '1 dup-twice']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_ ForthTest.test_user_defined_words_can_define_word_that_uses_word_with_the_same_name _
self = <forth_test.ForthTest testMethod=test_user_defined_words_can_define_word_that_uses_word_with_the_same_name>
code Copy code
def test_user_defined_words_can_define_word_that_uses_word_with_the_same_name(self):
code Copy code
self.assertEqual(evaluate([": foo 10 ;", ": foo foo 1 + ;", "foo"]), [11])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:227:
input_data = [': foo 10 ;', ': foo foo 1 + ;', 'foo']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______ ForthTest.test_user_defined_words_can_override_built_in_operators _______
self = <forth_test.ForthTest testMethod=test_user_defined_words_can_override_built_in_operators>
code Copy code
def test_user_defined_words_can_override_built_in_operators(self):
code Copy code
self.assertEqual(evaluate([": + * ;", "3 4 +"]), [12])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:219:
input_data = [': + * ;', '3 4 +']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
________ ForthTest.test_user_defined_words_can_override_built_in_words _________
self = <forth_test.ForthTest testMethod=test_user_defined_words_can_override_built_in_words>
code Copy code
def test_user_defined_words_can_override_built_in_words(self):
code Copy code
self.assertEqual(evaluate([": swap dup ;", "1 swap"]), [1, 1])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:216:
input_data = [': swap dup ;', '1 swap']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
___ ForthTest.test_user_defined_words_can_override_other_user_defined_words ____
self = <forth_test.ForthTest testMethod=test_user_defined_words_can_override_other_user_defined_words>
code Copy code
def test_user_defined_words_can_override_other_user_defined_words(self):
self.assertEqual(
code Copy code
evaluate([": foo dup ;", ": foo dup dup ;", "1 foo"]), [1, 1, 1]
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:212:
input_data = [': foo dup ;', ': foo dup dup ;', '1 foo']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_ ForthTest.test_user_defined_words_can_use_different_words_with_the_same_name _
self = <forth_test.ForthTest testMethod=test_user_defined_words_can_use_different_words_with_the_same_name>
code Copy code
def test_user_defined_words_can_use_different_words_with_the_same_name(self):
self.assertEqual(
code Copy code
evaluate([": foo 5 ;", ": bar foo ;", ": foo 6 ;", "bar foo"]), [5, 6]
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:223:
input_data = [': foo 5 ;', ': bar foo ;', ': foo 6 ;', 'bar foo']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
______ ForthTest.test_user_defined_words_cannot_redefine_negative_numbers ______
self = <forth_test.ForthTest testMethod=test_user_defined_words_cannot_redefine_negative_numbers>
code Copy code
def test_user_defined_words_cannot_redefine_negative_numbers(self):
with self.assertRaises(ValueError) as err:
code Copy code
evaluate([": -1 2 ;"])
forth_test.py:237:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
____ ForthTest.test_user_defined_words_cannot_redefine_non_negative_numbers ____
self = <forth_test.ForthTest testMethod=test_user_defined_words_cannot_redefine_non_negative_numbers>
code Copy code
def test_user_defined_words_cannot_redefine_non_negative_numbers(self):
with self.assertRaises(ValueError) as err:
code Copy code
evaluate([": 1 2 ;"])
forth_test.py:231:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
__ ForthTest.test_user_defined_words_errors_if_executing_a_non_existent_word ___
self = <forth_test.ForthTest testMethod=test_user_defined_words_errors_if_executing_a_non_existent_word>
code Copy code
def test_user_defined_words_errors_if_executing_a_non_existent_word(self):
with self.assertRaises(ValueError) as err:
code Copy code
evaluate(["foo"])
forth_test.py:243:
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
_________ ForthTest.test_user_defined_words_execute_in_the_right_order _________
self = <forth_test.ForthTest testMethod=test_user_defined_words_execute_in_the_right_order>
code Copy code
def test_user_defined_words_execute_in_the_right_order(self):
code Copy code
self.assertEqual(evaluate([": countup 1 2 3 ;", "countup"]), [1, 2, 3])
code Copy code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
forth_test.py:208:
input_data = [': countup 1 2 3 ;', 'countup']
code Copy code
def evaluate(input_data):
stack = []
code Copy code
words = input_data.upper().split()
code Copy code
^^^^^^^^^^^^^^^^
E AttributeError: 'list' object has no attribute 'upper'
forth.py:11: AttributeError
=========================== short test summary info ============================
FAILED forth_test.py::ForthTest::test_addition_can_add_two_numbers - Attribut...
FAILED forth_test.py::ForthTest::test_addition_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_addition_errors_if_there_is_only_one_value_on_the_stack
FAILED forth_test.py::ForthTest::test_addition_more_than_two_values_on_the_stack
FAILED forth_test.py::ForthTest::test_case_insensitivity_definitions_are_case_insensitive
FAILED forth_test.py::ForthTest::test_case_insensitivity_drop_is_case_insensitive
FAILED forth_test.py::ForthTest::test_case_insensitivity_dup_is_case_insensitive
FAILED forth_test.py::ForthTest::test_case_insensitivity_over_is_case_insensitive
FAILED forth_test.py::ForthTest::test_case_insensitivity_swap_is_case_insensitive
FAILED forth_test.py::ForthTest::test_case_insensitivity_user_defined_words_are_case_insensitive
FAILED forth_test.py::ForthTest::test_combined_arithmetic_addition_and_multiplication
FAILED forth_test.py::ForthTest::test_combined_arithmetic_addition_and_subtraction
FAILED forth_test.py::ForthTest::test_combined_arithmetic_multiplication_and_addition
FAILED forth_test.py::ForthTest::test_combined_arithmetic_multiplication_and_division
FAILED forth_test.py::ForthTest::test_division_can_divide_two_numbers - Attri...
FAILED forth_test.py::ForthTest::test_division_errors_if_dividing_by_zero - A...
FAILED forth_test.py::ForthTest::test_division_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_division_errors_if_there_is_only_one_value_on_the_stack
FAILED forth_test.py::ForthTest::test_division_more_than_two_values_on_the_stack
FAILED forth_test.py::ForthTest::test_division_performs_integer_division - At...
FAILED forth_test.py::ForthTest::test_drop_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_drop_removes_the_top_value_on_the_stack_if_it_is_not_the_only_one
FAILED forth_test.py::ForthTest::test_drop_removes_the_top_value_on_the_stack_if_it_is_the_only_one
FAILED forth_test.py::ForthTest::test_dup_copies_a_value_on_the_stack - Attri...
FAILED forth_test.py::ForthTest::test_dup_copies_the_top_value_on_the_stack
FAILED forth_test.py::ForthTest::test_dup_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_multiplication_can_multiply_two_numbers
FAILED forth_test.py::ForthTest::test_multiplication_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_multiplication_errors_if_there_is_only_one_value_on_the_stack
FAILED forth_test.py::ForthTest::test_multiplication_more_than_two_values_on_the_stack
FAILED forth_test.py::ForthTest::test_over_copies_the_second_element_if_there_are_more_than_two
FAILED forth_test.py::ForthTest::test_over_copies_the_second_element_if_there_are_only_two
FAILED forth_test.py::ForthTest::test_over_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_over_errors_if_there_is_only_one_value_on_the_stack
FAILED forth_test.py::ForthTest::test_parsing_and_numbers_numbers_just_get_pushed_onto_the_stack
FAILED forth_test.py::ForthTest::test_parsing_and_numbers_pushes_negative_numbers_onto_the_stack
FAILED forth_test.py::ForthTest::test_subtraction_can_subtract_two_numbers - ...
FAILED forth_test.py::ForthTest::test_subtraction_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_subtraction_errors_if_there_is_only_one_value_on_the_stack
FAILED forth_test.py::ForthTest::test_subtraction_more_than_two_values_on_the_stack
FAILED forth_test.py::ForthTest::test_swap_errors_if_there_is_nothing_on_the_stack
FAILED forth_test.py::ForthTest::test_swap_errors_if_there_is_only_one_value_on_the_stack
FAILED forth_test.py::ForthTest::test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_not_the_only_ones
FAILED forth_test.py::ForthTest::test_swap_swaps_the_top_two_values_on_the_stack_if_they_are_the_only_ones
FAILED forth_test.py::ForthTest::test_user_defined_words_can_consist_of_built_in_words
FAILED forth_test.py::ForthTest::test_user_defined_words_can_define_word_that_uses_word_with_the_same_name
FAILED forth_test.py::ForthTest::test_user_defined_words_can_override_built_in_operators
FAILED forth_test.py::ForthTest::test_user_defined_words_can_override_built_in_words
FAILED forth_test.py::ForthTest::test_user_defined_words_can_override_other_user_defined_words
FAILED forth_test.py::ForthTest::test_user_defined_words_can_use_different_words_with_the_same_name
FAILED forth_test.py::ForthTest::test_user_defined_words_cannot_redefine_negative_numbers
FAILED forth_test.py::ForthTest::test_user_defined_words_cannot_redefine_non_negative_numbers
FAILED forth_test.py::ForthTest::test_user_defined_words_errors_if_executing_a_non_existent_word
FAILED forth_test.py::ForthTest::test_user_defined_words_execute_in_the_right_order
============================== 54 failed ==============================
See the testing errors above.
The tests are correct, don't try and change them.
Fix the code in forth.py to resolve the errors.