File tree Expand file tree Collapse file tree
tests/arch/zx48k/optimizer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ class Asm(object):
1313 """
1414 def __init__ (self , asm ):
1515 assert isinstance (asm , str )
16+ asm = asm .strip ()
17+ assert asm , "Empty instruction '{}'" .format (asm )
1618 self .inst = Asm .inst (asm )
1719 self .oper = Asm .opers (asm )
1820 self .asm = '{} {}' .format (self .inst , ' ' .join (asm .split (' ' , 1 )[1 :])).strip ()
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+
3+ import unittest
4+ from arch .zx48k .optimizer import asm
5+
6+
7+ class TestASM (unittest .TestCase ):
8+ """ Tests optimizer Asm class
9+ """
10+ def test_spaces (self ):
11+ a = asm .Asm (' nop \t \n ' )
12+ self .assertEqual (a .asm , 'nop' )
13+
14+ def test_raises_error_on_empty_instruction (self ):
15+ self .assertRaises (AssertionError , asm .Asm , ' \t \n ' )
16+
17+ def test_unknown_instruction (self ):
18+ a = asm .Asm (' unknown instr ' )
19+ self .assertEqual (a .bytes , ())
You can’t perform that action at this time.
0 commit comments