def test_ast(): # create a new offline loader with explicit github url to local directory association loader = Loader() loader.add_repo("https://github.com/imodels/simgen.git", os.path.split(os.path.dirname(__file__))[0]) ast_node = AstNode(file_name='prg', loader=loader, search_path=['https://github.com/imodels/simgen/res/ast_test']) assert ast_node is not None assert ast_node.nodetype_name == 'add' assert ast_node.mapping['add'] is not None assert ast_node.mapping['add']['expr1'] is not None assert ast_node.mapping['add']['expr2'] is not None ast_node.validate()
def load_ast(self, file_name, inject_dict=None, validation=True): # find file log.debug('Loading ast from file: {}'.format(file_name)) # load ast ast = AstNode(file_name=file_name, loader=self.loader, code_path=self.code_path, concept_path=self.concept_path) log.debug("Ast loaded: {}".format(ast)) # inject values from inject_dict to replace placeholders in ast if inject_dict: ast.inject(inject_dict) # validate if validation: ast.validate() return ast
def test_ast(): # create a new offline loader with explicit github url to local directory association loader = Loader() loader.add_repo("https://github.com/imodels/simgen.git", os.path.split(os.path.dirname(__file__))[0]) ast_node = AstNode( file_name='prg', loader=loader, search_path=['https://github.com/imodels/simgen/res/ast_test']) assert ast_node is not None assert ast_node.nodetype_name == 'add' assert ast_node.mapping['add'] is not None assert ast_node.mapping['add']['expr1'] is not None assert ast_node.mapping['add']['expr2'] is not None ast_node.validate()