summaryrefslogtreecommitdiff
path: root/tests/arch
diff options
context:
space:
mode:
Diffstat (limited to 'tests/arch')
-rw-r--r--tests/arch/instruction.py52
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)