hdl.rec: improve repr() for Layout.

Fixes #326.
This commit is contained in:
whitequark 2020-04-12 04:47:40 +00:00
parent e9c75f7ca1
commit 7a08901117
2 changed files with 16 additions and 0 deletions

View file

@ -59,6 +59,13 @@ class LayoutTestCase(FHDLTestCase):
])
self.assertEqual(layout["a", "c"], expect)
def test_repr(self):
self.assertEqual(repr(Layout([("a", 1), ("b", signed(2))])),
"Layout([('a', unsigned(1)), ('b', signed(2))])")
self.assertEqual(repr(Layout([("a", 1), ("b", [("c", signed(3))])])),
"Layout([('a', unsigned(1)), "
"('b', Layout([('c', signed(3))]))])")
def test_wrong_field(self):
with self.assertRaises(TypeError,
msg="Field (1,) has invalid layout: should be either (name, shape) or "