lib.enum: use plain EnumMeta as metaclass when shape not used.
This commit is contained in:
parent
4e4085a95b
commit
1c3227d956
3 changed files with 25 additions and 12 deletions
|
|
@ -1077,7 +1077,7 @@ class SignalTestCase(FHDLTestCase):
|
|||
Signal(CastableFromHex(), reset="01")
|
||||
|
||||
def test_reset_shape_castable_enum_wrong(self):
|
||||
class EnumA(AmaranthEnum):
|
||||
class EnumA(AmaranthEnum, shape=1):
|
||||
X = 1
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
r"^Reset value must be a constant initializer of <enum 'EnumA'>$"):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import enum as py_enum
|
||||
|
||||
from amaranth import *
|
||||
from amaranth.lib.enum import Enum
|
||||
from amaranth.lib.enum import Enum, EnumMeta
|
||||
|
||||
from .utils import *
|
||||
|
||||
|
|
@ -91,14 +91,13 @@ class EnumTestCase(FHDLTestCase):
|
|||
A = 1
|
||||
self.assertRepr(Value.cast(EnumA.A), "(const 10'd1)")
|
||||
|
||||
def test_const_no_shape(self):
|
||||
def test_no_shape(self):
|
||||
class EnumA(Enum):
|
||||
Z = 0
|
||||
A = 10
|
||||
B = 20
|
||||
self.assertRepr(EnumA.const(None), "(const 5'd0)")
|
||||
self.assertRepr(EnumA.const(10), "(const 5'd10)")
|
||||
self.assertRepr(EnumA.const(EnumA.A), "(const 5'd10)")
|
||||
self.assertNotIsInstance(EnumA, EnumMeta)
|
||||
self.assertIsInstance(EnumA, py_enum.EnumMeta)
|
||||
|
||||
def test_const_shape(self):
|
||||
class EnumA(Enum, shape=8):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue