hdl.ast: make it impossible to construct *Castable instances.

Fixes #1072.
This commit is contained in:
Wanda 2024-02-09 03:09:42 +01:00 committed by Catherine
parent ace7aea375
commit 09854fa775
2 changed files with 22 additions and 0 deletions

View file

@ -191,6 +191,11 @@ class ShapeCastableTestCase(FHDLTestCase):
sc = MockShapeCastable(MockShapeCastable(unsigned(1)))
self.assertEqual(Shape.cast(sc), unsigned(1))
def test_abstract(self):
with self.assertRaisesRegex(TypeError,
r"^Can't instantiate abstract class ShapeCastable$"):
ShapeCastable()
class ShapeLikeTestCase(FHDLTestCase):
def test_construct(self):
@ -1400,6 +1405,11 @@ class ValueCastableTestCase(FHDLTestCase):
vc = MockValueCastable(MockValueCastable(Signal()))
self.assertIsInstance(Value.cast(vc), Signal)
def test_abstract(self):
with self.assertRaisesRegex(TypeError,
r"^Can't instantiate abstract class ValueCastable$"):
ValueCastable()
class ValueLikeTestCase(FHDLTestCase):
def test_construct(self):