hdl._ast: deprecate ValueCastable.lowermethod.

This commit is contained in:
Wanda 2024-02-13 05:21:39 +01:00 committed by Catherine
parent e2fd819742
commit 0da439cce1
7 changed files with 10 additions and 39 deletions

View file

@ -1040,7 +1040,6 @@ class ArrayTestCase(FHDLTestCase):
def test_index_value_castable(self):
class MyValue(ValueCastable):
@ValueCastable.lowermethod
def as_value(self):
return Signal()
@ -1328,7 +1327,6 @@ class MockValueCastable(ValueCastable):
def shape(self):
return Value.cast(self.dest).shape()
@ValueCastable.lowermethod
def as_value(self):
return self.dest
@ -1340,9 +1338,10 @@ class MockValueCastableChanges(ValueCastable):
def shape(self):
return unsigned(self.width)
@ValueCastable.lowermethod
def as_value(self):
return Signal(self.width)
with _ignore_deprecated():
@ValueCastable.lowermethod
def as_value(self):
return Signal(self.width)
class MockValueCastableCustomGetattr(ValueCastable):
@ -1352,29 +1351,16 @@ class MockValueCastableCustomGetattr(ValueCastable):
def shape(self):
assert False
@ValueCastable.lowermethod
def as_value(self):
return Const(0)
with _ignore_deprecated():
@ValueCastable.lowermethod
def as_value(self):
return Const(0)
def __getattr__(self, attr):
assert False
class ValueCastableTestCase(FHDLTestCase):
def test_not_decorated(self):
with self.assertRaisesRegex(TypeError,
r"^Class 'MockValueCastableNotDecorated' deriving from 'ValueCastable' must "
r"decorate the 'as_value' method with the 'ValueCastable.lowermethod' decorator$"):
class MockValueCastableNotDecorated(ValueCastable):
def __init__(self):
pass
def shape(self):
pass
def as_value(self):
return Signal()
def test_no_override(self):
with self.assertRaisesRegex(TypeError,
r"^Class 'MockValueCastableNoOverrideAsValue' deriving from 'ValueCastable' must "

View file

@ -4,7 +4,6 @@ import unittest
from types import SimpleNamespace as NS
from amaranth import *
from amaranth.hdl._ast import ValueCastable
from amaranth.lib import data, enum
from amaranth.lib.wiring import Flow, In, Out, Member
from amaranth.lib.wiring import SignatureError, SignatureMembers, FlippedSignatureMembers

View file

@ -728,7 +728,6 @@ class SimulatorIntegrationTestCase(FHDLTestCase):
def test_value_castable(self):
class MyValue(ValueCastable):
@ValueCastable.lowermethod
def as_value(self):
return Signal()