async def run_one_test_exception(test_data): """Run one interpreter test that generates an exception.""" source, expect = test_data global_ctx = GlobalContext("test", global_sym_table={}, manager=GlobalContextMgr) ast = AstEval("test", global_ctx=global_ctx) ast.parse(source) exc = ast.get_exception() if exc is not None: assert exc == expect return await ast.eval() exc = ast.get_exception() if exc is not None: assert exc == expect return assert False
async def run_one_test(test_data): """Run one interpreter test.""" source, expect = test_data global_ctx = GlobalContext("test", global_sym_table={}, manager=GlobalContextMgr) ast = AstEval("test", global_ctx=global_ctx) ast.parse(source) if ast.get_exception() is not None: print(f"Parsing {source} failed: {ast.get_exception()}") # print(ast.dump()) result = await ast.eval({"sym_local": 10}) assert result == expect