@@ -29,8 +29,11 @@ def assertAssemblesTo(self, source, expected):
29
29
f"Assembling { source !r} : Expected { expected_bin } , got { actual_bin } " ,
30
30
)
31
31
32
- def assertAssemblyFails (self , source ):
33
- self .assertRaises (RuntimeError , adafruit_pioasm .assemble , source )
32
+ def assertAssemblyFails (self , source , match = None , errtype = RuntimeError ):
33
+ if match :
34
+ self .assertRaisesRegex (errtype , match , adafruit_pioasm .assemble , source )
35
+ else :
36
+ self .assertRaises (errtype , adafruit_pioasm .assemble , source )
34
37
35
38
def testNonsense (self ):
36
39
self .assertAssemblyFails ("nope" )
@@ -52,6 +55,18 @@ def testSidesetOpt(self):
52
55
)
53
56
self .assertAssemblesTo (".side_set 1 opt\n nop [1]" , [0b101_00001_010_00_010 ])
54
57
58
+ def testMov (self ):
59
+ # non happy path
60
+ self .assertAssemblyFails (
61
+ "mov x, blah" , match = "Invalid mov source 'blah'" , errtype = ValueError
62
+ )
63
+
64
+ def testSet (self ):
65
+ # non happy path
66
+ self .assertAssemblyFails (
67
+ "set isr, 1" , match = "Invalid set destination 'isr'" , errtype = ValueError
68
+ )
69
+
55
70
def testJmp (self ):
56
71
self .assertAssemblesTo ("l:\n jmp l" , [0b000_00000_000_00000 ])
57
72
self .assertAssemblesTo ("l:\n jmp 7" , [0b000_00000_000_00111 ])
@@ -63,6 +78,10 @@ def testJmp(self):
63
78
self .assertAssemblesTo ("jmp x!=y, l\n l:" , [0b000_00000_101_00001 ])
64
79
self .assertAssemblesTo ("jmp pin, l\n l:" , [0b000_00000_110_00001 ])
65
80
self .assertAssemblesTo ("jmp !osre, l\n l:" , [0b000_00000_111_00001 ])
81
+ # non happy path
82
+ self .assertAssemblyFails (
83
+ "jmp x--., l\n l:" , match = "Invalid jmp condition 'x--.'" , errtype = ValueError
84
+ )
66
85
67
86
def testWait (self ):
68
87
self .assertAssemblesTo ("wait 0 gpio 0" , [0b001_00000_0_00_00000 ])
0 commit comments