def setUp(self): STR = "ZXBASIC" self.str_ = symbols.STRING(STR, 1) self.lower = symbols.NUMBER( 1, 1, type_=gl.SYMBOL_TABLE.basic_types[gl.STR_INDEX_TYPE]) self.upper = symbols.NUMBER( 2, 1, type_=gl.SYMBOL_TABLE.basic_types[gl.STR_INDEX_TYPE])
def visit_CHR(self, node): node = (yield self.generic_visit(node)) if all(chk.is_static(arg.value) for arg in node.operand): yield symbols.STRING(''.join( chr(src.api.utils.get_final_value(x.value) & 0xFF) for x in node.operand), node.lineno) else: yield node
def setUp(self): zxbpp.init() self.l = symbols.VAR('a', lineno=1, type_=Type.ubyte) self.r = symbols.NUMBER(3, lineno=2) self.b = symbols.BINARY('PLUS', self.l, self.r, lineno=3) self.st = symbols.STRING("ZXBASIC", lineno=1) if 'stderr' in OPTIONS: del OPTIONS.stderr OPTIONS(Action.ADD, name='stderr', default=StringIO())
def test__init__(self): self.assertRaises(AssertionError, symbols.STRING, 0, 1) _zxbasic = 'zxbasic' _ZXBASIC = 'ZXBASIC' s = symbols.STRING(_zxbasic, 1) t = symbols.STRING(_ZXBASIC, 2) self.assertEqual(s, s) self.assertNotEqual(s, t) self.assertEqual(s, _zxbasic) self.assertEqual(_ZXBASIC, t) self.assertGreater(s, t) self.assertLess(t, s) self.assertGreaterEqual(s, t) self.assertLessEqual(t, s) self.assertEqual(s.type_, Type.string) self.assertEqual(str(s), _zxbasic) self.assertEqual('"{}"'.format(_zxbasic), s.__repr__()) self.assertEqual(s.t, _zxbasic) s.t = _ZXBASIC self.assertEqual(s.t, _ZXBASIC) self.assertRaises(AssertionError, symbols.STRING.t.fset, s, 0) self.assertEqual(s.value, _zxbasic)
def test_string__setter(self): s = symbols.STRSLICE(self.str_, self.lower, self.upper, 1) tmp = symbols.STRING(self.str_.value * 2, 1) s.string = tmp self.assertEqual(s.string, tmp)
def test_is_temporary_value_const_string(self): node = symbols.STRING("Hello world", 1) self.assertFalse(check.is_temporary_value(node))