class Test def main is shared x as int expect AssertException x = 0 assert x try expect AssertException x = 1 assert x catch ee as ExpectException assert 'no exception' in ee.message assert ee.expectedExceptionType == AssertException assert ee.actualException is nil success throw Exception('Expecting ExpectException') try expect AssertException throw SystemException() catch ee as ExpectException assert 'different exception' in ee.message assert ee.expectedExceptionType == AssertException assert ee.actualException inherits SystemException success throw Exception('Expecting ExpectException') # test nested expect expect ExpectException expect AssertException x = 1 assert x # test expecting root Exception type expect Exception .throwException # test nested expect and root Exception type expect ExpectException expect Exception Test() def throwException is shared throw Exception('test exception')