hdl.dsl: cases wider than switch test value are unreachable.
In 3083c1d6 they were erroneously fixed via truncation.
This commit is contained in:
parent
3083c1d6dd
commit
664b4bcb3a
3 changed files with 13 additions and 11 deletions
|
|
@ -289,14 +289,12 @@ class DSLTestCase(FHDLTestCase):
|
|||
pass
|
||||
with self.assertWarns(SyntaxWarning,
|
||||
msg="Case value '10110' is wider than test (which has width 4); comparison "
|
||||
"will be made against truncated value"):
|
||||
"will never be true"):
|
||||
with m.Case(0b10110):
|
||||
pass
|
||||
self.assertRepr(m._statements, """
|
||||
(
|
||||
(switch (sig w1)
|
||||
(case 0110 )
|
||||
)
|
||||
(switch (sig w1) )
|
||||
)
|
||||
""")
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@ __all__ = ["FHDLTestCase"]
|
|||
class FHDLTestCase(unittest.TestCase):
|
||||
def assertRepr(self, obj, repr_str):
|
||||
obj = Statement.wrap(obj)
|
||||
repr_str = re.sub(r"\s+", " ", repr_str)
|
||||
repr_str = re.sub(r"\( (?=\()", "(", repr_str)
|
||||
repr_str = re.sub(r"\) (?=\))", ")", repr_str)
|
||||
self.assertEqual(repr(obj), repr_str.strip())
|
||||
def prepare_repr(repr_str):
|
||||
repr_str = re.sub(r"\s+", " ", repr_str)
|
||||
repr_str = re.sub(r"\( (?=\()", "(", repr_str)
|
||||
repr_str = re.sub(r"\) (?=\))", ")", repr_str)
|
||||
return repr_str.strip()
|
||||
self.assertEqual(prepare_repr(repr(obj)), prepare_repr(repr_str))
|
||||
|
||||
@contextmanager
|
||||
def assertRaises(self, exception, msg=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue