diff python/testasm.py @ 193:f091e7d70996

Added even more checks
author Windel Bouwman
date Sun, 26 May 2013 23:58:59 +0200
parents 6b2bec5653f1
children b01429a5d695
line wrap: on
line diff
--- a/python/testasm.py	Sun May 26 23:19:27 2013 +0200
+++ b/python/testasm.py	Sun May 26 23:58:59 2013 +0200
@@ -17,10 +17,17 @@
         self.assertSequenceEqual([tok.typ for tok in libasm.tokenize(asmline)], toks)
 
     def testLex1(self):
+        """ Test if lexer correctly maps some tokens """
         asmline, toks = 'lab1: mov rax, rbx ', ['ID', ':', 'ID', 'ID', ',', 'ID']
         self.assertSequenceEqual([tok.typ for tok in libasm.tokenize(asmline)], toks)
 
+    def testLex1(self):
+        """ Test if lexer correctly maps some tokens """
+        asmline, toks = 'mov 3.13 0xC 13', ['ID', 'REAL', 'NUMBER', 'NUMBER']
+        self.assertSequenceEqual([tok.typ for tok in libasm.tokenize(asmline)], toks)
+
     def testLex2(self):
+        """ Test if lexer fails on a token that is invalid """
         asmline = '0z4: mov rax, rbx $ '
         with self.assertRaises(ppci.CompilerError):
             list(libasm.tokenize(asmline))
@@ -30,6 +37,11 @@
         a = libasm.Assembler()
         a.assembleLine(asmline)
 
+    def testParse2(self):
+        asmline = 'a: mov rax, [rbx + 2]'
+        a = libasm.Assembler()
+        a.assembleLine(asmline)
+
 if __name__ == '__main__':
     unittest.main()