def test_describe_cpp(): rc = parse_global_rc() clang_includes = rc.clang_includes if "clang_includes" in rc else () testdir = os.path.dirname(__file__) fname = os.path.join(testdir, "toaster.h") buildbase = os.path.join(testdir, "build") ts.register_class("Base", ("T", "i"), cpp_type="Base") ts.register_class("Point", ("B", "C"), cpp_type="Point") ts.register_classname("Toaster", "toaster", "toaster", "cpp_toaster") for name in "NoDefaultBase", "NoDefault", "Default": ts.register_class(name, cpp_type=name) def check(parser): goals = ( ("class", ("Base", "int32", 7, 0), exp_base_desc(parser)), ("class", ("Point", True, "CA", 0), exp_point_desc), ("class", "Toaster", exp_toaster_desc), ("func", "simple", exp_simple_desc), # Verify that we pick up parameter names from definitions ("func", "twice", exp_twice_desc), # Verify that the first parameter name declaration wins ("func", "conflict", exp_conflict_desc), ("func", ("lasso", 17, "int32", "float32"), exp_lasso_desc(17)), ("func", ("lasso", 18, "int32", "float32"), exp_lasso_desc(18)), ("class", "Default", exp_default_desc), ("class", "NoDefaultBase", exp_nodefault_base_desc), ("class", "NoDefault", exp_nodefault_desc), ("var", "Choices", exp_choices_desc), ) for kind, name, exp in goals: obs = ad.describe( fname, name=name, kind=kind, parsers=parser, builddir=buildbase + "-" + parser, verbose=False, ts=ts, clang_includes=clang_includes, ) assert_equal_or_diff(obs, exp) for parser in "gccxml", "clang": cleanfs(buildbase + "-" + parser) if PARSERS_AVAILABLE[parser]: yield check, parser else: yield skip_then_continue, parser + " unavailable"
def test_describe_cpp(): rc = parse_global_rc() clang_includes = rc.clang_includes if 'clang_includes' in rc else () testdir = os.path.dirname(__file__) fname = os.path.join(testdir, 'toaster.h') buildbase = os.path.join(testdir, 'build') ts.register_class('Base', ('T', 'i'), cpp_type='Base') ts.register_class('Point', ('B', 'C'), cpp_type='Point') ts.register_classname('Toaster', 'toaster', 'toaster', 'cpp_toaster') for name in 'NoDefaultBase', 'NoDefault', 'Default': ts.register_class(name, cpp_type=name) def check(parser): goals = ( ('class', ('Base', 'int32', 7, 0), exp_base_desc(parser)), ('class', ('Point', True, 'CA', 0), exp_point_desc), ('class', 'Toaster', exp_toaster_desc), ('func', 'simple', exp_simple_desc), # Verify that we pick up parameter names from definitions ('func', 'twice', exp_twice_desc), # Verify that the first parameter name declaration wins ('func', 'conflict', exp_conflict_desc), ('func', ('lasso', 17, 'int32', 'float32'), exp_lasso_desc(17)), ('func', ('lasso', 18, 'int32', 'float32'), exp_lasso_desc(18)), ('class', 'Default', exp_default_desc), ('class', 'NoDefaultBase', exp_nodefault_base_desc), ('class', 'NoDefault', exp_nodefault_desc), ('var', 'Choices', exp_choices_desc)) for kind, name, exp in goals: obs = ad.describe(fname, name=name, kind=kind, parsers=parser, builddir=buildbase + '-' + parser, verbose=False, ts=ts, clang_includes=clang_includes) assert_equal_or_diff(obs, exp) for parser in 'gccxml', 'clang': cleanfs(buildbase + '-' + parser) if PARSERS_AVAILABLE[parser]: yield check, parser else: yield skip_then_continue, parser + ' unavailable'
def test_autoall(): rc = parse_global_rc() clang_includes = rc.clang_includes if 'clang_includes' in rc else () exp_var = ['Choice'] exp_fun = ['foo'] exp_cls = ['Blah'] testdir = os.path.dirname(__file__) filename = os.path.join(testdir, 'all.h') buildbase = os.path.join(testdir, 'build') def check_all(parser): obs_var, obs_fun, obs_cls = autoall.findall(filename, parsers=parser, builddir=buildbase + '-' + parser, clang_includes=clang_includes) assert_equal_or_diff(obs_var, exp_var) assert_equal_or_diff(obs_fun, exp_fun) assert_equal_or_diff(obs_cls, exp_cls) for parser in 'gccxml', 'clang': cleanfs(buildbase + '-' + parser) if PARSERS_AVAILABLE[parser]: yield check_all, parser else: yield skip_then_continue, parser + ' unavailable'
def test_describe_cpp(): rc = parse_global_rc() clang_includes = rc.clang_includes if 'clang_includes' in rc else () testdir = os.path.dirname(__file__) fname = os.path.join(testdir, 'toaster.h') buildbase = os.path.join(testdir, 'build') ts.register_class('Base', ('T', 'i'), cpp_type='Base') ts.register_class('Point', ('B', 'C'), cpp_type='Point') ts.register_classname('Toaster', 'toaster', 'toaster', 'cpp_toaster') for name in 'NoDefaultBase', 'NoDefault', 'Default': ts.register_class(name, cpp_type=name) def check(parser): goals = (('class', ('Base', 'int32', 7, 0), exp_base_desc(parser)), ('class', ('Point', True, 'CA', 0), exp_point_desc), ('class', 'Toaster', exp_toaster_desc), ('func', 'simple', exp_simple_desc), # Verify that we pick up parameter names from definitions ('func', 'twice', exp_twice_desc), # Verify that the first parameter name declaration wins ('func', 'conflict', exp_conflict_desc), ('func', ('lasso', 17, 'int32', 'float32'), exp_lasso_desc(17)), ('func', ('lasso', 18, 'int32', 'float32'), exp_lasso_desc(18)), ('class', 'Default', exp_default_desc), ('class', 'NoDefaultBase', exp_nodefault_base_desc), ('class', 'NoDefault', exp_nodefault_desc), ('var', 'Choices', exp_choices_desc)) for kind, name, exp in goals: obs = ad.describe(fname, name=name, kind=kind, parsers=parser, builddir=buildbase + '-' + parser, verbose=False, ts=ts, clang_includes=clang_includes) assert_equal_or_diff(obs, exp) for parser in 'gccxml', 'clang': cleanfs(buildbase + '-' + parser) if PARSERS_AVAILABLE[parser]: yield check, parser else: yield skip_then_continue, parser + ' unavailable'