def test_garbage_collected_dsl_raises_runtime_error(): mnemonic = Mnemonic('FOO') asm = AsmDsl() labeller = asm.label del asm gc.collect() with raises(RuntimeError): labeller(mnemonic)
def test_mnemonic_repr(m): r = repr(Mnemonic(m)) assert r.startswith('Mnemonic') assert m in r assert check_balanced(r)
def test_mnemonic_value(m): assert str(Mnemonic(m)) == m
def test_mnemonic_illegal_initial_character_raises_value_error(m): with raises(ValueError): Mnemonic(m)
def test_empty_mnemonic_raises_value_error(): with raises(ValueError): Mnemonic('')
def test_mnemonic_interning(m): assert Mnemonic(m) is Mnemonic(m)
def test_mnemonic_illegal_unicode_categories_raise_value_error(p, q): m = p + q with raises(ValueError): Mnemonic(m)
def test_negative_indirect_address_raises_value_error(address): FOO = Mnemonic('FOO') asm = AsmDsl() with raises(ValueError): asm(FOO, {address})
def test_parse_operand_unsupported_indirect_type_raises_not_implemented_error( ): FOO = Mnemonic('FOO') asm = AsmDsl() with raises(TypeError): asm(FOO, [object()])
def test_unknown_mnemonic_raises_value_error(): mnemonic = Mnemonic("XXX") asm = AsmDsl() with raises(ValueError): asm(mnemonic)
def test_unknown_mnemonic_raises_value_error(m): mnemonic = Mnemonic(m) assume(mnemonic not in MNEMONIC_TO_STATEMENT) asm = AsmDsl() with raises(ValueError): asm(mnemonic)