Skip to content

Commit

Permalink
Update error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Nov 8, 2018
1 parent 5308df7 commit 0b99995
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion magma/t.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __le__(self, other):
if self.isinput():
self.wire(other)
else:
raise TypeError("Cannot use <= to assign to an output")
raise TypeError(f"Cannot use <= to assign to output: {self.debug_name} (trying to assign {other.debug_name})")


class Kind(type):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def test_assign_error_0(width):
"c", m.Out(T))
and2 = DeclareAnd(width)()
try:
and2.O = circ.a
and2.O <= circ.a
assert False, "Should raise type error"
except TypeError as e:
assert str(e) == f"Cannot assign to output port of instance: test_assign_operator_{width}.And{width}_inst0.O"
assert str(e) == f"Cannot use <= to assign to output: {and2.O.debug_name} (trying to assign {circ.a.debug_name})"


@pytest.mark.parametrize("width", [None, 3])
Expand All @@ -77,7 +77,7 @@ def test_assign_error_1(width):
"c", m.Out(T))
and2 = DeclareAnd(width)()
try:
circ.a = and2.O
circ.a <= and2.O
assert False, "Should raise type error"
except TypeError as e:
assert str(e) == f"Cannot assign to input port of definition: test_assign_operator_{width}.a"
assert str(e) == f"Cannot use <= to assign to output: {circ.a.debug_name} (trying to assign {and2.O.debug_name})"

0 comments on commit 0b99995

Please sign in to comment.