From 18ad8f03c6568f66f678c8f193b30ecb16074fcf Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Sat, 11 Feb 2023 17:36:15 +0000 Subject: [PATCH] more test --- asm/test.py | 42 ++++++++++++++++++++++++++++++------------ 1 file 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()