aboutsummaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2023-02-11 17:36:15 +0000
committerGravatar Peter McGoron 2023-02-11 17:36:15 +0000
commit18ad8f03c6568f66f678c8f193b30ecb16074fcf (patch)
treec2bfe71d1b947130e4dd75018388e3b39e8f4735 /asm
parentadd stack overflow and underflow tests (diff)
more test
Diffstat (limited to 'asm')
-rw-r--r--asm/test.py42
1 files changed, 30 insertions, 12 deletions
diff --git a/asm/test.py b/asm/test.py
index bddf0a3..1f66a4a 100644
--- a/asm/test.py
+++ b/asm/test.py
@@ -185,7 +185,7 @@ class AddTest(unittest.TestCase):
self.assertEqual(ex.cenv.reg[0], 30)
self.assertEqual(ex.cenv.reg[1], word_2c(10))
- def test_exec_mul_throw_imm(self):
+ def test_exec_add_throw_imm(self):
p = Program()
with self.assertRaises(TypecheckException) as cm:
p.parse_asm_line("add 5 6 7")
@@ -194,16 +194,7 @@ class AddTest(unittest.TestCase):
self.assertEqual(cm.exception.i, 0)
self.assertEqual(cm.exception.opcode, 3)
- def test_exec_mul_throw_imm(self):
- p = Program()
- with self.assertRaises(TypecheckException) as cm:
- p.parse_asm_line("add 5 6 7")
- self.assertEqual(cm.exception.argtype, ArgType.REG)
- self.assertEqual(cm.exception.sarg, '5')
- self.assertEqual(cm.exception.i, 0)
- self.assertEqual(cm.exception.opcode, 3)
-
- def test_exec_mul_throw_lab_1(self):
+ def test_exec_add_throw_lab_1(self):
p = Program()
with self.assertRaises(TypecheckException) as cm:
p.parse_asm_line("add r0 l6 7")
@@ -212,7 +203,7 @@ class AddTest(unittest.TestCase):
self.assertEqual(cm.exception.i, 1)
self.assertEqual(cm.exception.opcode, 3)
- def test_exec_mul_throw_lab_2(self):
+ def test_exec_add_throw_lab_2(self):
p = Program()
with self.assertRaises(TypecheckException) as cm:
p.parse_asm_line("add r0 12 l24")
@@ -240,6 +231,33 @@ class MulTest(unittest.TestCase):
self.assertEqual(ex.cenv.reg[0], word_2c(25))
self.assertEqual(ex.cenv.reg[1], 125)
+ def test_exec_mul_throw_imm(self):
+ p = Program()
+ with self.assertRaises(TypecheckException) as cm:
+ p.parse_asm_line("mul 942 6 7")
+ self.assertEqual(cm.exception.argtype, ArgType.REG)
+ self.assertEqual(cm.exception.sarg, '942')
+ self.assertEqual(cm.exception.i, 0)
+ self.assertEqual(cm.exception.opcode, 4)
+
+ def test_exec_mul_throw_lab_1(self):
+ p = Program()
+ with self.assertRaises(TypecheckException) as cm:
+ p.parse_asm_line("mul r9 l2 1991")
+ self.assertEqual(cm.exception.argtype, ArgType.VAL)
+ self.assertEqual(cm.exception.sarg, 'l2')
+ self.assertEqual(cm.exception.i, 1)
+ self.assertEqual(cm.exception.opcode, 4)
+
+ def test_exec_mul_throw_lab_2(self):
+ p = Program()
+ with self.assertRaises(TypecheckException) as cm:
+ p.parse_asm_line("mul r0 -11 l48")
+ self.assertEqual(cm.exception.argtype, ArgType.VAL)
+ self.assertEqual(cm.exception.sarg, 'l48')
+ self.assertEqual(cm.exception.i, 2)
+ self.assertEqual(cm.exception.opcode, 4)
+
class ProgramTest(unittest.TestCase):
def test_exec_simple_reg(self):
p = Program()