hdl._ast: enforce the ShapeCastable.const contract in Const().

This commit is contained in:
Wanda 2024-04-02 12:04:51 +02:00 committed by Catherine
parent 5577f4e703
commit c4bbcc6f8a
5 changed files with 18 additions and 11 deletions

View file

@ -522,10 +522,16 @@ class ConstTestCase(FHDLTestCase):
hash(Const(0))
def test_shape_castable(self):
class MockConstValue:
class MockConstValue(ValueCastable):
def __init__(self, value):
self.value = value
def shape(self):
return MockConstShape()
def as_value(self):
return Const(self.value, 8)
class MockConstShape(ShapeCastable):
def as_shape(self):
return unsigned(8)