def test_single_digit_addition_no_whitespace(self): self.text = "1+1" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) result = self.interpreter.expr() self.assertEqual(result, eval(self.text))
def test_floor_division_with_truncated_result(self): self.text = " 3 / 2" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) result = self.interpreter.expr() self.assertEqual(result, int(eval(self.text)))
def test_three_term_expression(self): self.text = "1 + 5 / 2" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) result = self.interpreter.expr() self.assertEqual(result, int(eval(self.text)))
def test_multiplication(self): self.text = "2 * 3" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) result = self.interpreter.expr() self.assertEqual(result, eval(self.text))
def test_subtraction(self): self.text = "13 - 12" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) result = self.interpreter.expr() self.assertEqual(result, eval(self.text))
def test_integer_multidigit_plus_digit(self): self.text = "123+4" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) one_twenty_seven = self.interpreter.expr() self.assertEqual(one_twenty_seven, eval(self.text))
def test_integer_double_digit(self): self.text = "12" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) twelve = self.interpreter.expr() self.assertEqual(twelve, eval(self.text))
def test_integer_single_digit(self): self.text = "1" self.lexer = Lexer(self.text) self.interpreter = Interpreter(self.lexer) one = self.interpreter.expr() self.assertEqual(one, eval(self.text))