コード例 #1
0
 def test_invalid_token_raises_exception(self):
     interpreter = Interpreter('')
     interpreter.current_token = Token(PLUS, '+')
     with self.assertRaises(InvalidTokenException) as exc:
         interpreter.eat([DIVIDE, MULTIPLY])
コード例 #2
0
 def test_valid_token_calls_get_next_token(self):
     interpreter = Interpreter('')
     with patch.object(interpreter, 'get_next_token') as get_next_token:
         interpreter.current_token = Token(PLUS, '+')
         interpreter.eat([PLUS, SUBTRACT, DIVIDE, MULTIPLY])
     self.assertTrue(get_next_token.called)