hdl.ir: typecheck convert(ports=) more carefully.
The `ports` argument to the `convert` functions is a frequent hotspot of beginner issues. Check to make sure it is either a list or a tuple, and give an appropriately helpful error message if not. Fixes #362.
This commit is contained in:
parent
fd7f69f7a5
commit
f2b4584b34
2 changed files with 16 additions and 0 deletions
|
|
@ -304,6 +304,16 @@ class FragmentPortsTestCase(FHDLTestCase):
|
|||
msg="Only signals may be added as ports, not (const 1'd1)"):
|
||||
f.prepare(ports=(Const(1),))
|
||||
|
||||
def test_port_not_iterable(self):
|
||||
f = Fragment()
|
||||
with self.assertRaises(TypeError,
|
||||
msg="`ports` must be either a list or a tuple, not 1"):
|
||||
f.prepare(ports=1)
|
||||
with self.assertRaises(TypeError,
|
||||
msg="`ports` must be either a list or a tuple, not (const 1'd1)" +
|
||||
" (did you mean `ports=(<signal>,)`, rather than `ports=<signal>`?)"):
|
||||
f.prepare(ports=Const(1))
|
||||
|
||||
class FragmentDomainsTestCase(FHDLTestCase):
|
||||
def test_iter_signals(self):
|
||||
cd1 = ClockDomain()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue