def check(name, input, idDict, output=None): # first a simple check of the AST if output is None: output = input ast = parse(name, input) res = str(ast) if res != output: print("") print("Input: ", input) print("Result: ", res) print("Expected: ", output) raise DefinitionError("") rootSymbol = Symbol(None, None, None, None, None, None) symbol = rootSymbol.add_declaration(ast, docname="TestDoc") parentNode = addnodes.desc() signode = addnodes.desc_signature(input, '') parentNode += signode ast.describe_signature(signode, 'lastIsName', symbol, options={}) idExpected = [None] for i in range(1, _max_id + 1): if i in idDict: idExpected.append(idDict[i]) else: idExpected.append(idExpected[i - 1]) idActual = [None] for i in range(1, _max_id + 1): try: id = ast.get_id(version=i) assert id is not None idActual.append(id[len(_id_prefix[i]):]) except NoOldIdError: idActual.append(None) res = [True] for i in range(1, _max_id + 1): res.append(idExpected[i] == idActual[i]) if not all(res): print("input: %s" % input.rjust(20)) for i in range(1, _max_id + 1): if res[i]: continue print("Error in id version %d." % i) print("result: %s" % idActual[i]) print("expected: %s" % idExpected[i]) print(rootSymbol.dump(0)) raise DefinitionError("")
def check(name, input, idv1output=None, idv2output=None, output=None): # first a simple check of the AST if output is None: output = input ast = parse(name, input) res = text_type(ast) if res != output: print("") print("Input: ", text_type(input)) print("Result: ", res) print("Expected: ", output) raise DefinitionError("") rootSymbol = Symbol(None, None, None, None, None, None) symbol = rootSymbol.add_declaration(ast, docname="TestDoc") parentNode = addnodes.desc() signode = addnodes.desc_signature(input, '') parentNode += signode ast.describe_signature(signode, 'lastIsName', symbol, options={}) if idv2output: idv2output = "_CPPv2" + idv2output try: idv1 = ast.get_id_v1() assert idv1 is not None except NoOldIdError: idv1 = None try: idv2 = ast.get_id_v2() assert idv2 is not None except NoOldIdError: idv2 = None if idv1 != idv1output or idv2 != idv2output: print("input: %s" % text_type(input).rjust(20)) print(" %s %s" % ("Id v1".rjust(20), "Id v2".rjust(20))) print("result: %s %s" % (str(idv1).rjust(20), str(idv2).rjust(20))) print("expected: %s %s" % (str(idv1output).rjust(20), str(idv2output).rjust(20))) print(rootSymbol.dump(0)) raise DefinitionError("") ids.append(ast.get_id_v2())