123456789101112131415161718192021222324252627 |
- import unittest
-
- from gte.turmit import Turmit
- from gte.rpnlib import _op_list, RpnSymbol, RpnExpr
-
- class RpnExprTestCase(unittest.TestCase):
-
- def test_init(self):
- expr = RpnExpr()
-
- def test_random(self):
- expr = RpnExpr.random(5)
- self.assertEqual(len(expr), 5)
-
- def test_fromstring(self):
- expr = RpnExpr.from_string(""" 5 0xFF
- X
- \tMOD""")
- self.assertEqual(len(expr), 4)
- tests = ((RpnSymbol.VALUE, 5),
- (RpnSymbol.VALUE, 255),
- (RpnSymbol.VARIABLE, 'x'),
- (RpnSymbol.OPERATION, 'mod'))
- for i, (optype, val) in enumerate(tests):
- self.assertEqual(expr[i].optype, optype)
- self.assertEqual(expr[i].value, val)
|