def test_free_parser(): """ HelloWorld.cbl and HelloWorldFree.cbl must have the same ast. """ with open('test/testfiles/HelloWorld.cbl') as f: content = f.read() non_free_ast, non_free_vars, non_free_procs = parser.defined_names(content) with open('test/testfiles/HelloWorldFree.cbl') as f: content = f.read() free_ast, free_vars, free_procs = parser.defined_names(content, free_format=True) result = parser.cmp_name(non_free_ast, free_ast) assert result
def test_free_parser(): """ HelloWorld.cbl and HelloWorldFree.cbl must have the same ast. """ with open('test/testfiles/HelloWorld.cbl') as f: content = f.read() non_free_ast, non_free_vars, non_free_procs = parser.defined_names(content) with open('test/testfiles/HelloWorldFree.cbl') as f: content = f.read() free_ast, free_vars, free_procs = parser.defined_names( content, free_format=True) result = parser.cmp_name(non_free_ast, free_ast) assert result
def test_copy_book(): with open('test/testfiles/test.cpy') as f: content = f.read() ast, vars, procs = parser.defined_names(content) # 8 variables assert len(vars) == 21 assert vars[0].name == 'txt-lower'
def complete(self, code, *_): global free_format, lower_case_keywords completions = [] try: root, vars, functions = defined_names( code, free_format=free_format) except AttributeError: vars = [] functions = [] for var in vars: completions.append({ 'name': var.name, 'icon': icons.ICON_VAR, 'tooltip': var.description }) for func in functions: completions.append({ 'name': func.name, 'icon': icons.ICON_FUNC }) if lower_case_keywords: completions += [{'name': k['name'].lower(), 'icon': k['icon']} for k in self._kwds] else: completions += self._kwds return completions
def test_lvl88(): """ See OpenCobolIDE/OpenCobolIDE#95, first comment """ with open('test/testfiles/TEST_LVL_88.cbl') as f: content = f.read() ast, vars, procs = parser.defined_names(content) assert len(vars) == 10
def test_structure(): # see OpenCobolIDE/OpenCobolIDE#336 with open('test/testfiles/structure.cbl') as f: content = f.read() ast, vars, procs = parser.defined_names(content) l5_1_node = ast.children[0].children[0].children[0].children[0].children[1] assert len(l5_1_node.children) == 2
def test_variables(): """ Virtual printer must have 8 vars """ with open('test/testfiles/VIRTUAL-PRINTER.cbl') as f: content = f.read() ast, vars, procs = parser.defined_names(content) # 8 variables assert len(vars) == 8
def test_paragraphes(): """ Test printer must have 2 procedures """ with open('test/testfiles/TEST-PRINTER.cbl') as f: content = f.read() ast, vars, procs = parser.defined_names(content) # 1 procedure assert len(procs) == 2
def test_malformed(): """ Parses the hello world example """ with open('test/testfiles/MALFORMED.cbl') as f: content = f.read() ast, vars, procs = parser.defined_names(content) # 4 divs assert len(ast.children) == 4 # 2 sections in env div assert len(ast.children[0].children) == 2 # 2 sections in data div assert len(ast.children[1].children) == 3 assert len(vars) == 3 assert len(procs) == 1
def test_parse_names(): """ Parses the hello world example """ with open('test/testfiles/HelloWorld.cbl') as f: content = f.read() ast, vars, procs = parser.defined_names(content) # 4 divs assert len(ast.children) == 4 # 2 sections in env div assert len(ast.children[1].children) == 2 # 2 sections in data div assert len(ast.children[2].children) == 2 assert len(vars) == 0 assert len(procs) == 1
def test_parse_pco(): """ Parses a pco file, which contains characters in column 1-6 (see bug #23) """ with open('test/testfiles/HelloWorld.pco') as f: content = f.read() ast, vars, procs = parser.defined_names(content) # 4 divs assert len(ast.children) == 4 # 2 sections in env div assert len(ast.children[1].children) == 2 # 2 sections in data div assert len(ast.children[2].children) == 2 assert len(vars) == 0 assert len(procs) == 1
def complete(self, code, line, column, completionPrefix, file_path, file_encoding): global free_format completions = [] try: root, vars, functions = defined_names( code, free_format=free_format) except AttributeError: vars = [] functions = [] for var in vars: completions.append({ 'name': var.name, 'icon': icons.ICON_VAR, 'tooltip': var.description }) for func in functions: completions.append({ 'name': func.name, 'icon': icons.ICON_FUNC }) completions += self.__keywordsCompletions return completions
def get_outline(data): if free_format is None: return None else: root_node, _, _ = defined_names(data['code'], free_format) return [ch.to_definition().to_dict() for ch in root_node.children]
def get_outline(data): root_node, _, _ = defined_names(data['code'], free_format) return [ch.to_definition().to_dict() for ch in root_node.children]