Commit 802efc02 authored by Dylan Trotter's avatar Dylan Trotter

Fix silently dropping assertions at the top level of a block....

Fix silently dropping assertions at the top level of a block. https://github.com/google/grumpy/issues/18
parent d973ec21
......@@ -45,6 +45,20 @@ class StatementVisitorTest(unittest.TestCase):
except AssertionError as e:
print repr(e)""")))
def testBareAssert(self):
# Assertion errors at the top level of a block should raise:
# https://github.com/google/grumpy/issues/18
want = (0, 'ok\n')
self.assertEqual(want, _GrumpRun(textwrap.dedent("""\
def foo():
assert False
try:
foo()
except AssertionError:
print 'ok'
else:
print 'bad'""")))
def testAssignAttribute(self):
self.assertEqual((0, '123\n'), _GrumpRun(textwrap.dedent("""\
e = Exception()
......
......@@ -105,7 +105,7 @@ class Writer(object):
def write_checked_call1(self, call, *args, **kwargs):
return self.write_tmpl(textwrap.dedent("""\
if raised := $call; raised != nil {
if πE = $call; πE != nil {
\tcontinue
}"""), call=call.format(*args, **kwargs))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment