Rename remaining wrap methods to cast.

Following commit d72d4a55.
This commit is contained in:
whitequark 2019-10-11 13:28:26 +00:00
parent a658cb2bbf
commit b90687c988
7 changed files with 34 additions and 22 deletions

View file

@ -13,7 +13,7 @@ class UnsignedEnum(Enum):
class LayoutTestCase(FHDLTestCase):
def test_fields(self):
layout = Layout.wrap([
layout = Layout.cast([
("cyc", 1),
("data", signed(32)),
("stb", 1, DIR_FANOUT),
@ -34,7 +34,7 @@ class LayoutTestCase(FHDLTestCase):
self.assertEqual(sublayout["b"], ((1, False), DIR_NONE))
def test_enum_field(self):
layout = Layout.wrap([
layout = Layout.cast([
("enum", UnsignedEnum),
("enum_dir", UnsignedEnum, DIR_FANOUT),
])
@ -42,18 +42,18 @@ class LayoutTestCase(FHDLTestCase):
self.assertEqual(layout["enum_dir"], ((2, False), DIR_FANOUT))
def test_range_field(self):
layout = Layout.wrap([
layout = Layout.cast([
("range", range(0, 7)),
])
self.assertEqual(layout["range"], ((3, False), DIR_NONE))
def test_slice_tuple(self):
layout = Layout.wrap([
layout = Layout.cast([
("a", 1),
("b", 2),
("c", 3)
])
expect = Layout.wrap([
expect = Layout.cast([
("a", 1),
("c", 3)
])
@ -63,29 +63,29 @@ class LayoutTestCase(FHDLTestCase):
with self.assertRaises(TypeError,
msg="Field (1,) has invalid layout: should be either (name, shape) or "
"(name, shape, direction)"):
Layout.wrap([(1,)])
Layout.cast([(1,)])
def test_wrong_name(self):
with self.assertRaises(TypeError,
msg="Field (1, 1) has invalid name: should be a string"):
Layout.wrap([(1, 1)])
Layout.cast([(1, 1)])
def test_wrong_name_duplicate(self):
with self.assertRaises(NameError,
msg="Field ('a', 2) has a name that is already present in the layout"):
Layout.wrap([("a", 1), ("a", 2)])
Layout.cast([("a", 1), ("a", 2)])
def test_wrong_direction(self):
with self.assertRaises(TypeError,
msg="Field ('a', 1, 0) has invalid direction: should be a Direction "
"instance like DIR_FANIN"):
Layout.wrap([("a", 1, 0)])
Layout.cast([("a", 1, 0)])
def test_wrong_shape(self):
with self.assertRaises(TypeError,
msg="Field ('a', 'x') has invalid shape: should be castable to Shape or "
"a list of fields of a nested record"):
Layout.wrap([("a", "x")])
Layout.cast([("a", "x")])
class RecordTestCase(FHDLTestCase):

View file

@ -22,7 +22,7 @@ class SimulatorUnitTestCase(FHDLTestCase):
stmt = stmt(osig, *isigs)
frag = Fragment()
frag.add_statements(stmt)
for signal in flatten(s._lhs_signals() for s in Statement.wrap(stmt)):
for signal in flatten(s._lhs_signals() for s in Statement.cast(stmt)):
frag.add_driver(signal)
with Simulator(frag,

View file

@ -20,7 +20,7 @@ __all__ = ["FHDLTestCase"]
class FHDLTestCase(unittest.TestCase):
def assertRepr(self, obj, repr_str):
if isinstance(obj, list):
obj = Statement.wrap(obj)
obj = Statement.cast(obj)
def prepare_repr(repr_str):
repr_str = re.sub(r"\s+", " ", repr_str)
repr_str = re.sub(r"\( (?=\()", "(", repr_str)