hdl.dsl: improve error messages for Case().
This commit is contained in:
parent
32310aecad
commit
f292a1977c
2 changed files with 40 additions and 17 deletions
|
|
@ -359,12 +359,12 @@ class DSLTestCase(FHDLTestCase):
|
|||
m = Module()
|
||||
with m.Switch(self.w1):
|
||||
with self.assertRaises(SyntaxError,
|
||||
msg="Case value '--' must have the same width as test (which is 4)"):
|
||||
msg="Case pattern '--' must have the same width as switch value (which is 4)"):
|
||||
with m.Case("--"):
|
||||
pass
|
||||
with self.assertWarns(SyntaxWarning,
|
||||
msg="Case value '10110' is wider than test (which has width 4); comparison "
|
||||
"will never be true"):
|
||||
msg="Case pattern '10110' is wider than switch value (which has width 4); "
|
||||
"comparison will never be true"):
|
||||
with m.Case(0b10110):
|
||||
pass
|
||||
self.assertRepr(m._statements, """
|
||||
|
|
@ -373,6 +373,22 @@ class DSLTestCase(FHDLTestCase):
|
|||
)
|
||||
""")
|
||||
|
||||
def test_Case_bits_wrong(self):
|
||||
m = Module()
|
||||
with m.Switch(self.w1):
|
||||
with self.assertRaises(SyntaxError,
|
||||
msg="Case pattern 'abc' must consist of 0, 1, and - (don't care) bits"):
|
||||
with m.Case("abc"):
|
||||
pass
|
||||
|
||||
def test_Case_pattern_wrong(self):
|
||||
m = Module()
|
||||
with m.Switch(self.w1):
|
||||
with self.assertRaises(SyntaxError,
|
||||
msg="Case pattern must be an integer or a string, not 1.0"):
|
||||
with m.Case(1.0):
|
||||
pass
|
||||
|
||||
def test_Case_outside_Switch_wrong(self):
|
||||
m = Module()
|
||||
with self.assertRaises(SyntaxError,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue