diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2025-04-01 00:05:16 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2025-04-01 00:05:16 (GMT) |
commit | bb7e4c5e6e4c51da0d9b1a33b571b0c64851c1a8 (patch) | |
tree | 4575210322bf6838f538a4f58967c0a2a0d9cabc /tests/arch | |
parent | 70ed4dc99c75c13797b41164959c753ffbc4572b (diff) |
Restore most features of core instructions.gtk4
Diffstat (limited to 'tests/arch')
-rw-r--r-- | tests/arch/instruction.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/arch/instruction.py b/tests/arch/instruction.py new file mode 100644 index 0000000..da4d8c1 --- /dev/null +++ b/tests/arch/instruction.py @@ -0,0 +1,52 @@ + +import pychrysalide +from chrysacase import ChrysalideTestCase +from pychrysalide.arch import ArchInstruction + + +class TestProcessor(ChrysalideTestCase): + """TestCase for arch.ArchProcessor.""" + + + def testAbstractClass(self): + """Forbid instruction class instance.""" + + with self.assertRaisesRegex(RuntimeError, 'pychrysalide.arch.ArchInstruction is an abstract class'): + ins = ArchInstruction() + + + def testInstructionBasicImplementation(self): + """Implement basic custom instructions.""" + + + class TodoInstruction(ArchInstruction): + + def __init__(self): + super().__init__(0x123) + + + ins = TodoInstruction() + + with self.assertRaisesRegex(NotImplementedError, 'unexpected NULL value as encoding'): + print(ins.encoding) + + with self.assertRaisesRegex(NotImplementedError, 'unexpected NULL value as keyword'): + print(ins.keyword) + + + class CustomInstruction(ArchInstruction): + + def __init__(self): + super().__init__(0x123) + + def _get_encoding(self): + return 'custom' + + def _get_keyword(self): + return 'kw' + + + ins = CustomInstruction() + + self.assertEqual('custom', ins.encoding) + self.assertEqual('kw', ins.keyword) |