hdl.ast: improve repr() for Shape.

The default __repr__() from typing.NamedTuple does not include
the module name, so the replacement (which uses the preferred syntax
for specifying these shapes) doesn't either.
This commit is contained in:
whitequark 2020-04-12 03:59:56 +00:00
parent 9055090f65
commit e9c75f7ca1
2 changed files with 10 additions and 0 deletions

View file

@ -39,6 +39,10 @@ class ShapeTestCase(FHDLTestCase):
msg="Width must be a non-negative integer, not -1"):
Shape(-1)
def test_repr(self):
self.assertEqual(repr(Shape()), "unsigned(1)")
self.assertEqual(repr(Shape(2, True)), "signed(2)")
def test_tuple(self):
width, signed = Shape()
self.assertEqual(width, 1)