You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This works, but is probably not OK for some reason
class Assert(AbstractStatement):
"""
Assertion used within a protocol.
"""
def __init__(self, expr):
super(Assert, self).__init__()
self.expr = expr
def evaluate(self, env):
result = self.expr.evaluate(env)
try:
ok = result.value
except AttributeError:
raise ProtocolError("Assertion did not yield a Simple value or 0-d Array.")
if not ok:
if isinstance(self.expr, E.Eq):
operands = self.expr.evaluate_children(env)
lhs = operands[0].value
rhs = operands[1].value
raise ProtocolError(f'Assertion failed: {lhs} != {rhs}.')
raise ProtocolError("Assertion failed.")
return V.Null()
E.g. "assert x == 2" could return "Assertion failed: 2000 != 2" instead of just "Assertain failed" with "x == 2" somewhere in the stacktrace
The text was updated successfully, but these errors were encountered: