lib.data: at most one Union field can have annotation with a default.

This commit is contained in:
Catherine 2023-03-04 09:34:36 +00:00
parent e2ce959c90
commit ae1aeff0f2
2 changed files with 13 additions and 0 deletions

View file

@ -679,6 +679,14 @@ class UnionTestCase(FHDLTestCase):
self.assertEqual(s.attrs, {"debug": 1})
self.assertEqual(s.decoder, decoder)
def test_define_reset_two_wrong(self):
with self.assertRaisesRegex(ValueError,
r"^Reset value for at most one field can be provided for a union class "
r"\(specified: a, b\)$"):
class U(Union):
a: unsigned(1) = 1
b: unsigned(2) = 1
def test_construct_reset_two_wrong(self):
class U(Union):
a: unsigned(1)