creole/asm_test.py

24 lines
600 B
Python

from creole_asm import *
import unittest
class ProgramTest(unittest.TestCase):
def test_oneline(self):
p = Program()
p.parse_asm_line("PUSH r0")
b = p()
self.assertEqual(b, b'\x01\xC2\x80\x00')
def test_large_reg(self):
p = Program(regnum=0x8000000)
p.parse_asm_line("PUSH r134217727")
b = p()
self.assertEqual(b, b'\x01\xFC\x87\xbf\xbf\xbf\xbf\x00')
def test_two(self):
p = Program()
p.parse_asm_line("PUSH r1")
p.parse_asm_line("ADD r1 5 6")
b = p()
self.assertEqual(b, b'\x01\xC2\x81\x00\x03\xC2\x81\xC0\x85\xC0\x86\x00')
if __name__ == "__main__":
unittest.main()