lib.enum: allow empty enums.
This commit is contained in:
parent
e6d8d5a354
commit
7e438180e0
2 changed files with 10 additions and 12 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import enum as py_enum
|
||||
|
||||
from amaranth import *
|
||||
from amaranth.lib.enum import Enum
|
||||
|
||||
|
|
@ -21,9 +23,10 @@ class EnumTestCase(FHDLTestCase):
|
|||
def test_shape_no_members(self):
|
||||
class EnumA(Enum):
|
||||
pass
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
r"^Enumeration '.+?\.EnumA' does not have a defined shape$"):
|
||||
Shape.cast(EnumA)
|
||||
class PyEnumA(py_enum.Enum):
|
||||
pass
|
||||
self.assertEqual(Shape.cast(EnumA), unsigned(0))
|
||||
self.assertEqual(Shape.cast(PyEnumA), unsigned(0))
|
||||
|
||||
def test_shape_explicit(self):
|
||||
class EnumA(Enum, shape=signed(2)):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue