Implement RFC 42: Const from shape-castable.
This commit is contained in:
parent
089213e19f
commit
5e2f3b7992
2 changed files with 28 additions and 2 deletions
|
|
@ -470,6 +470,25 @@ class ConstTestCase(FHDLTestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
hash(Const(0))
|
||||
|
||||
def test_shape_castable(self):
|
||||
class MockConstValue:
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
class MockConstShape(ShapeCastable):
|
||||
def as_shape(self):
|
||||
return unsigned(8)
|
||||
|
||||
def __call__(self, value):
|
||||
return value
|
||||
|
||||
def const(self, init):
|
||||
return MockConstValue(init)
|
||||
|
||||
s = Const(10, MockConstShape())
|
||||
self.assertIsInstance(s, MockConstValue)
|
||||
self.assertEqual(s.value, 10)
|
||||
|
||||
|
||||
class OperatorTestCase(FHDLTestCase):
|
||||
def test_bool(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue