Exemplo n.º 1
0
    def __test_type_transformation(self, ns_name, transformer):
        ns_control = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name=ns_name)
        self.failUnless(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_before = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='before')
        self.failUnless(ns_before, "unable to find 'before' namespace")
        ns_after = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='after')
        self.failUnless(ns_after, "unable to find 'after' namespace")

        for tbefore in ns_before.declarations:
            tafter = declarations.find_declaration(
                ns_after,
                name=tbefore.name)
            self.failUnless(
                tafter,
                "unable to find transformed type definition for type '%s'" %
                tbefore.decl_string)
            transformed = transformer(tbefore)
            self.failUnless(
                declarations.is_same(
                    transformed,
                    tafter),
                ("there is a difference between expected type and result. " +
                 "typedef name: %s") % tbefore.decl_string)
Exemplo n.º 2
0
    def __test_type_category(self, ns_name, controller):
        ns_control = declarations.find_declaration(
            self.declarations, type=declarations.namespace_t, name=ns_name)
        self.assertTrue(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_yes = declarations.find_declaration(ns_control,
                                               type=declarations.namespace_t,
                                               name='yes')
        self.assertTrue(ns_yes, "unable to find 'yes' namespace")
        ns_no = declarations.find_declaration(ns_control,
                                              type=declarations.namespace_t,
                                              name='no')
        self.assertTrue(ns_no, "unable to find 'no' namespace")
        er = 'for type "%s" the answer to the question "%s" should be True'
        for decl in ns_yes.declarations:
            if isinstance(decl, declarations.variable_t):
                self.assertTrue(controller(decl.type),
                                er % (decl.type.decl_string, ns_name))
            elif isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue
            else:
                self.assertTrue(controller(decl),
                                er % (decl.decl_string, ns_name))
        er = 'for type "%s" the answer to the question "%s" should be False'
        for decl in ns_no.declarations:
            if isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue

            self.failIf(controller(decl), er % (decl.decl_string, ns_name))
Exemplo n.º 3
0
    def __test_type_transformation(self, ns_name, transformer):
        ns_control = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.namespace_t,
            name=ns_name)
        self.assertTrue(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_before = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='before')
        self.assertTrue(ns_before, "unable to find 'before' namespace")
        ns_after = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='after')
        self.assertTrue(ns_after, "unable to find 'after' namespace")

        for tbefore in ns_before.declarations:
            tafter = declarations.find_declaration(
                ns_after,
                name=tbefore.name)
            self.assertTrue(
                tafter,
                "unable to find transformed type definition for type '%s'" %
                tbefore.decl_string)
            transformed = transformer(tbefore)
            self.assertTrue(
                declarations.is_same(
                    transformed,
                    tafter),
                ("there is a difference between expected type '{0}' " +
                 "and result '{1}'. typedef name: {2}").format(
                    declarations.remove_declarated(tafter).decl_string,
                    declarations.remove_declarated(transformed).decl_string,
                    tbefore.decl_string))
Exemplo n.º 4
0
    def __test_type_transformation(self, ns_name, transformer):
        ns_control = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.namespace_t,
            name=ns_name)
        self.assertTrue(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_before = declarations.find_declaration(
            ns_control, decl_type=declarations.namespace_t, name='before')
        self.assertTrue(ns_before, "unable to find 'before' namespace")
        ns_after = declarations.find_declaration(
            ns_control, decl_type=declarations.namespace_t, name='after')
        self.assertTrue(ns_after, "unable to find 'after' namespace")

        for tbefore in ns_before.declarations:
            tafter = declarations.find_declaration(ns_after, name=tbefore.name)
            self.assertTrue(
                tafter,
                "unable to find transformed type definition for type '%s'" %
                tbefore.decl_string)
            transformed = transformer(tbefore)
            self.assertTrue(
                declarations.is_same(transformed, tafter),
                ("there is a difference between expected type '{0}' " +
                 "and result '{1}'. typedef name: {2}").format(
                     declarations.remove_declarated(tafter).decl_string,
                     declarations.remove_declarated(transformed).decl_string,
                     tbefore.decl_string))
Exemplo n.º 5
0
    def test_is_base_and_derived(self):
        ns = declarations.find_declaration(self.declarations,
                                           decl_type=declarations.namespace_t,
                                           name='is_base_and_derived')
        self.assertTrue(ns, "unable to find 'is_base_and_derived' namespace")
        base = declarations.find_declaration(ns.declarations,
                                             decl_type=declarations.class_t,
                                             name='base')
        derived = declarations.find_declaration(ns.declarations,
                                                decl_type=declarations.class_t,
                                                name='derived')
        self.assertTrue(base and derived
                        and declarations.is_base_and_derived(base, derived))
        self.assertTrue(
            base and derived
            and declarations.is_base_and_derived(base, (derived, derived)))

        unrelated1 = declarations.find_declaration(
            ns.declarations, decl_type=declarations.class_t, name='unrelated1')

        unrelated2 = declarations.find_declaration(
            ns.declarations, decl_type=declarations.class_t, name='unrelated2')
        self.assertTrue(
            base and derived
            and not declarations.is_base_and_derived(unrelated1, unrelated2))
Exemplo n.º 6
0
    def test_is_base_and_derived(self):
        ns = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name='is_base_and_derived')
        self.failUnless(ns, "unable to find 'is_base_and_derived' namespace")
        base = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='base')
        derived = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='derived')
        self.failUnless(
            base and derived and declarations.is_base_and_derived(
                base,
                derived))
        self.failUnless(
            base and derived and
            declarations.is_base_and_derived(base, (derived, derived)))

        unrelated1 = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='unrelated1')

        unrelated2 = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='unrelated2')
        self.failUnless(
            base and derived and not declarations.is_base_and_derived(
                unrelated1,
                unrelated2))
Exemplo n.º 7
0
    def __test_type_category(self, ns_name, controller):
        ns_control = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name=ns_name)
        self.failUnless(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_yes = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='yes')
        self.failUnless(ns_yes, "unable to find 'yes' namespace")
        ns_no = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='no')
        self.failUnless(ns_no, "unable to find 'no' namespace")
        er = 'for type "%s" the answer to the question "%s" should be True'
        for decl in ns_yes.declarations:
            if isinstance(decl, declarations.variable_t):
                self.failUnless(
                    controller(decl.type),
                    er % (decl.type.decl_string, ns_name))
            elif isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue
            else:
                self.failUnless(
                    controller(decl), er % (decl.decl_string, ns_name))
        er = 'for type "%s" the answer to the question "%s" should be False'
        for decl in ns_no.declarations:
            if isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue

            self.failIf(controller(decl), er % (decl.decl_string, ns_name))
 def __is_convertible_impl( self, decl ):
     defs = decl.bases[0].related_class.declarations
     source_type = declarations.find_declaration( defs, name='source_type' )
     target_type = declarations.find_declaration( defs, name='target_type' )
     expected_type = declarations.find_declaration( defs
                                                    , name='expected'
                                                    , type=declarations.enumeration_t )
     expected_value = bool( expected_type.get_name2value_dict()['value'] )
     self.failUnless( expected_value == declarations.is_convertible( source_type, target_type )
                      , 'Check conversion failed for ' + decl.name )
 def __check_result(self, decls):
     E11 = declarations.find_declaration(decls, fullname='::E11')
     self.assertTrue(E11, "unable to find 'E11' enum")
     ns12 = declarations.find_declaration(decls, fullname='::ns::ns12')
     self.assertTrue(ns12, "unable to find 'ns12' namespace")
     E13 = declarations.find_declaration(ns12.declarations, name='E13')
     self.assertTrue(E13, "unable to find 'E13' enum")
     E14 = declarations.find_declaration(decls, name='E14')
     self.assertTrue(not E14,
                     "enum 'E14' should not be found in declarations")
 def __check_result(self, decls):
     E11 = declarations.find_declaration(decls, fullname='::E11')
     self.assertTrue(E11, "unable to find 'E11' enum")
     ns12 = declarations.find_declaration(decls, fullname='::ns::ns12')
     self.assertTrue(ns12, "unable to find 'ns12' namespace")
     E13 = declarations.find_declaration(ns12.declarations, name='E13')
     self.assertTrue(E13, "unable to find 'E13' enum")
     E14 = declarations.find_declaration(decls, name='E14')
     self.assertTrue(
         not E14,
         "enum 'E14' should not be found in declarations")
Exemplo n.º 11
0
 def __is_convertible_impl(self, decl):
     defs = decl.bases[0].related_class.declarations
     source_type = declarations.find_declaration(defs, name='source_type')
     target_type = declarations.find_declaration(defs, name='target_type')
     expected_type = declarations.find_declaration(
         defs, name='expected', decl_type=declarations.enumeration_t)
     expected_value = bool(expected_type.get_name2value_dict()['value'])
     self.assertTrue(
         expected_value == declarations.is_convertible(
             source_type, target_type),
         'Check conversion failed for ' + decl.name)
Exemplo n.º 12
0
 def __is_convertible_impl( self, decl ):
     if decl.name == 'x81':
         i = 0
     defs = decl.bases[0].related_class.declarations
     source_type = declarations.find_declaration( defs, name='source_type' )
     target_type = declarations.find_declaration( defs, name='target_type' )
     expected_type = declarations.find_declaration( defs
                                                    , name='expected'
                                                    , type=declarations.enumeration_t )
     expected_value = bool( expected_type.get_name2value_dict()['value'] )
     if expected_value != declarations.is_convertible( source_type, target_type ):
         print decl.name
Exemplo n.º 13
0
 def test_numeric_patcher(self):
     fix_numeric = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_numeric' )
     self.failUnless( fix_numeric, "Free function fix_numeric has not been found." )
     if 32 == self.architecture:
         self.failUnless( fix_numeric.arguments[0].default_value == u"0xffffffffffffffff" )
     else: 
         self.failUnless( fix_numeric.arguments[0].default_value == u"0ffffffff" )
Exemplo n.º 14
0
 def setUp(self):
     if not self.declarations:
         self.declarations = parser.parse( [self.header], self.config )
         self.global_ns = declarations.find_declaration( self.declarations
                                                         , type=declarations.namespace_t
                                                         , name='::' )
         self.global_ns.init_optimizer()
Exemplo n.º 15
0
 def test(self):
     item_cls = declarations.find_declaration(
         self.declarations, decl_type=declarations.class_t, name='item_t')
     self.assertTrue(item_cls, "unable to find class 'item_t'")
     self.assertTrue(len(item_cls.aliases) == 3)
     expected_aliases = {'Item', 'Item1', 'Item2'}
     real_aliases = set([typedef.name for typedef in item_cls.aliases])
     self.assertTrue(real_aliases == expected_aliases)
    def test_is_convertible( self ):
        ns_is_convertible = declarations.find_declaration( self.declarations
                                                           , type=declarations.namespace_t
                                                           , name="is_convertible" )

        self.failUnless( ns_is_convertible, "namespace is_convertible was not found" )
        for tester in filter( lambda decl: decl.name.startswith( 'x' ), ns_is_convertible.declarations ):
            self.__is_convertible_impl( tester )
Exemplo n.º 17
0
    def __test_type_category(self, ns_name, controller):
        ns_control = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.namespace_t,
            name=ns_name)
        self.assertTrue(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_yes = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='yes')
        self.assertTrue(ns_yes, "unable to find 'yes' namespace")
        ns_no = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='no')
        self.assertTrue(ns_no, "unable to find 'no' namespace")
        er = 'for type "%s" the answer to the question "%s" should be True'
        for decl in ns_yes.declarations:
            if isinstance(decl, declarations.variable_t):
                self.assertTrue(
                    controller(decl.decl_type),
                    er % (decl.decl_type.decl_string, ns_name))
            elif isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue
            else:
                self.assertTrue(
                    controller(decl), er % (decl.decl_string, ns_name))
        er = 'for type "%s" the answer to the question "%s" should be False'
        generator = self.xml_generator_from_xml_file
        for decl in ns_no.declarations:
            if isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue

            if generator.is_castxml1 or (
                    generator.is_castxml and
                    float(generator.xml_output_version) < 1.138):
                if decl.name in ['const_item', 'const_container']:
                    # Skip this test to workaround CastXML bug.
                    # See https://github.com/CastXML/CastXML/issues/55
                    continue

            self.assertFalse(
                controller(decl),
                er % (decl.decl_string, ns_name))
Exemplo n.º 18
0
 def setUp(self):
     if not self.declarations:
         self.declarations = parser.parse([self.header], self.config)
         self.global_ns = declarations.find_declaration(
             self.declarations,
             type=declarations.namespace_t,
             name='::')
         self.global_ns.init_optimizer()
Exemplo n.º 19
0
 def test( self ):                
     item_cls = declarations.find_declaration( self.declarations
                                           , type=declarations.class_t
                                           , name='item_t' )
     self.failUnless( item_cls, "unable to find class 'item_t'" )
     self.failUnless( len( item_cls.aliases ) == 3 )
     expected_aliases = set( ['Item', 'Item1', 'Item2' ] )
     real_aliases = set( map( lambda typedef: typedef.name, item_cls.aliases ) )
     self.failUnless( real_aliases == expected_aliases )
Exemplo n.º 20
0
 def test(self):
     item_cls = declarations.find_declaration(self.declarations,
                                              type=declarations.class_t,
                                              name='item_t')
     self.failUnless(item_cls, "unable to find class 'item_t'")
     self.failUnless(len(item_cls.aliases) == 3)
     expected_aliases = set(['Item', 'Item1', 'Item2'])
     real_aliases = set(map(lambda typedef: typedef.name, item_cls.aliases))
     self.failUnless(real_aliases == expected_aliases)
Exemplo n.º 21
0
    def __test_type_category(self, ns_name, controller):
        ns_control = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name=ns_name)
        self.assertTrue(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_yes = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='yes')
        self.assertTrue(ns_yes, "unable to find 'yes' namespace")
        ns_no = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='no')
        self.assertTrue(ns_no, "unable to find 'no' namespace")
        er = 'for type "%s" the answer to the question "%s" should be True'
        for decl in ns_yes.declarations:
            if isinstance(decl, declarations.variable_t):
                self.assertTrue(
                    controller(decl.type),
                    er % (decl.type.decl_string, ns_name))
            elif isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue
            else:
                self.assertTrue(
                    controller(decl), er % (decl.decl_string, ns_name))
        er = 'for type "%s" the answer to the question "%s" should be False'
        for decl in ns_no.declarations:
            if isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue

            if ("CastXML" in utils.xml_generator and
                    utils.xml_output_version < 1.138 and
                    decl.name in ['const_item', 'const_container']):
                # Skip this test to workaround CastXML bug.
                # See https://github.com/CastXML/CastXML/issues/55
                continue

            self.assertFalse(
                controller(decl),
                er % (decl.decl_string, ns_name))
Exemplo n.º 22
0
 def test(self):
     item_cls = declarations.find_declaration(
         self.declarations,
         type=declarations.class_t,
         name='item_t')
     self.assertTrue(item_cls, "unable to find class 'item_t'")
     self.assertTrue(len(item_cls.aliases) == 3)
     expected_aliases = set(['Item', 'Item1', 'Item2'])
     real_aliases = set([typedef.name for typedef in item_cls.aliases])
     self.assertTrue(real_aliases == expected_aliases)
Exemplo n.º 23
0
    def test(self):
        fconfig = parser.file_configuration_t(
            data="int i;", start_with_declarations=None, content_type=parser.file_configuration_t.CONTENT_TYPE.TEXT
        )

        prj_reader = parser.project_reader_t(self.config)
        decls = prj_reader.read_files([fconfig], compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)

        var_i = declarations.find_declaration(decls, type=declarations.variable_t, name="i")
        self.failUnless(var_i, "Variable i has not been found.")
Exemplo n.º 24
0
    def test_is_convertible(self):
        ns_is_convertible = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name="is_convertible")

        self.failUnless(ns_is_convertible,
                        "namespace is_convertible was not found")
        for tester in filter(lambda decl: decl.name.startswith('x'),
                             ns_is_convertible.declarations):
            self.__is_convertible_impl(tester)
Exemplo n.º 25
0
    def test_is_unary_binary_operator(self):
        operator_not = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.operator_t,
            fullname='::is_unary_operator::dummy::operator!')
        self.assertTrue(operator_not, 'operator! was not found')
        self.assertTrue(declarations.is_unary_operator(operator_not),
                        'operator! should be idenitified as unary operator')
        self.assertTrue(not declarations.is_binary_operator(operator_not),
                        'operator! should be idenitified as unary operator')

        operator_class_p = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.operator_t,
            fullname='::is_unary_operator::dummy::operator+')
        self.assertTrue(operator_class_p, 'operator+ was not found')
        self.assertTrue(not declarations.is_unary_operator(operator_class_p),
                        'operator+ should be idenitified as binary operator')
        self.assertTrue(declarations.is_binary_operator(operator_class_p),
                        'operator! should be idenitified as binary operator')

        operator_class_pp = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.operator_t,
            fullname='::is_unary_operator::dummy::operator++')
        self.assertTrue(operator_class_pp, 'operator++ was not found')
        self.assertTrue(declarations.is_unary_operator(operator_class_pp),
                        'operator++ should be idenitified as unary operator')
        self.assertTrue(not declarations.is_binary_operator(operator_class_pp),
                        'operator++ should be idenitified as unary operator')

        operator_pp = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.operator_t,
            fullname='::is_unary_operator::operator++')
        self.assertTrue(operator_pp, 'operator++ was not found')
        self.assertTrue(declarations.is_unary_operator(operator_pp),
                        'operator++ should be idenitified as unary operator')
        self.assertTrue(not declarations.is_binary_operator(operator_pp),
                        'operator++ should be idenitified as unary operator')

        operator_mm = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.operator_t,
            fullname='::is_unary_operator::operator*')
        self.assertTrue(operator_mm, 'operator-- was not found')
        self.assertTrue(not declarations.is_unary_operator(operator_mm),
                        'operator-- should be idenitified as binary operator')
        self.assertTrue(declarations.is_binary_operator(operator_mm),
                        'operator-- should be idenitified as binray operator')

        operator_pe = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.operator_t,
            fullname='::is_unary_operator::operator+=')
        self.assertTrue(operator_pe, 'operator+= was not found')
        self.assertTrue(not declarations.is_unary_operator(operator_pe),
                        'operator+= should be idenitified as binary operator')
        self.assertTrue(declarations.is_binary_operator(operator_pe),
                        'operator+= should be idenitified as binray operator')
Exemplo n.º 26
0
    def test(self):
        fconfig = parser.file_configuration_t(
            data='int i;',
            start_with_declarations=None,
            content_type=parser.file_configuration_t.CONTENT_TYPE.TEXT)

        prj_reader = parser.project_reader_t(self.config)
        decls = prj_reader.read_files(
            [fconfig], compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)

        var_i = declarations.find_declaration(
            decls, decl_type=declarations.variable_t, name='i')
        self.assertTrue(var_i, "Variable i has not been found.")
Exemplo n.º 27
0
    def test_is_convertible(self):
        ns_is_convertible = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.namespace_t,
            name="is_convertible")

        self.assertTrue(ns_is_convertible,
                        "namespace is_convertible was not found")
        for tester in [
                decl for decl in ns_is_convertible.declarations
                if decl.name.startswith('x')
        ]:

            self.__is_convertible_impl(tester)
Exemplo n.º 28
0
    def test_is_convertible(self):
        ns_is_convertible = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name="is_convertible")

        self.failUnless(
            ns_is_convertible,
            "namespace is_convertible was not found")
        for tester in [
            decl for decl in ns_is_convertible.declarations if
                decl.name.startswith('x')]:

            self.__is_convertible_impl(tester)
Exemplo n.º 29
0
    def __test_type_transformation(self, ns_name, transformer):
        ns_control = declarations.find_declaration(
            self.declarations, type=declarations.namespace_t, name=ns_name)
        self.failUnless(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_before = declarations.find_declaration(
            ns_control, type=declarations.namespace_t, name='before')
        self.failUnless(ns_before, "unable to find 'before' namespace")
        ns_after = declarations.find_declaration(ns_control,
                                                 type=declarations.namespace_t,
                                                 name='after')
        self.failUnless(ns_after, "unable to find 'after' namespace")

        for tbefore in ns_before.declarations:
            tafter = declarations.find_declaration(ns_after, name=tbefore.name)
            self.failUnless(
                tafter,
                "unable to find transformed type definition for type '%s'" %
                tbefore.decl_string)
            transformed = transformer(tbefore)
            self.failUnless(
                declarations.is_same(transformed, tafter),
                "there is a difference between expected type and result. typedef name: %s"
                % tbefore.decl_string)
Exemplo n.º 30
0
 def test_by_location(self):
     reader = parser.source_reader_t( self.config )
     decls = reader.read_file( self.__fname )
     decls_count = len( declarations.make_flatten( decls ) )
     filtered = declarations.filtering.by_location( decls, [autoconfig.data_directory] )
     flatten_filtered = declarations.make_flatten( filtered )
     self.failUnless( len( flatten_filtered  ) != decls_count )
     for decl in flatten_filtered:
         if decl.location:
             self.failUnless( declarations.filtering.normalize_path( decl.location.file_name )
                              , self.__fpath )
     self.failUnless( declarations.find_declaration( filtered
                                                     , name='color'
                                                     , type=declarations.enumeration_t
                                                     , recursive=False) )
    def test_is_unary_binary_operator(self):
        operator_not = declarations.find_declaration( self.declarations
                                                      , type=declarations.operator_t
                                                      , fullname='::is_unary_operator::dummy::operator!' )
        self.failUnless( operator_not, 'operator! was not found' )
        self.failUnless( declarations.is_unary_operator( operator_not ), 'operator! should be idenitified as unary operator' )
        self.failUnless( not declarations.is_binary_operator( operator_not ), 'operator! should be idenitified as unary operator' )

        operator_class_p = declarations.find_declaration( self.declarations
                                                          , type=declarations.operator_t
                                                          , fullname='::is_unary_operator::dummy::operator+' )
        self.failUnless( operator_class_p, 'operator+ was not found' )
        self.failUnless( not declarations.is_unary_operator( operator_class_p ), 'operator+ should be idenitified as binary operator' )
        self.failUnless( declarations.is_binary_operator( operator_class_p ), 'operator! should be idenitified as binary operator' )

        operator_class_pp = declarations.find_declaration( self.declarations
                                                           , type=declarations.operator_t
                                                           , fullname='::is_unary_operator::dummy::operator++' )
        self.failUnless( operator_class_pp, 'operator++ was not found' )
        self.failUnless( declarations.is_unary_operator( operator_class_pp ), 'operator++ should be idenitified as unary operator' )
        self.failUnless( not declarations.is_binary_operator( operator_class_pp ), 'operator++ should be idenitified as unary operator' )

        operator_pp = declarations.find_declaration( self.declarations
                                                     , type=declarations.operator_t
                                                     , fullname='::is_unary_operator::operator++' )
        self.failUnless( operator_pp, 'operator++ was not found' )
        self.failUnless( declarations.is_unary_operator( operator_pp ), 'operator++ should be idenitified as unary operator' )
        self.failUnless( not declarations.is_binary_operator( operator_pp ), 'operator++ should be idenitified as unary operator' )

        operator_mm = declarations.find_declaration( self.declarations
                                                     , type=declarations.operator_t
                                                     , fullname='::is_unary_operator::operator*' )
        self.failUnless( operator_mm, 'operator-- was not found' )
        self.failUnless( not declarations.is_unary_operator( operator_mm ), 'operator-- should be idenitified as binary operator' )
        self.failUnless( declarations.is_binary_operator( operator_mm ), 'operator-- should be idenitified as binray operator' )

        operator_pe = declarations.find_declaration( self.declarations
                                                     , type=declarations.operator_t
                                                     , fullname='::is_unary_operator::operator+=' )
        self.failUnless( operator_pe, 'operator+= was not found' )
        self.failUnless( not declarations.is_unary_operator( operator_pe ), 'operator+= should be idenitified as binary operator' )
        self.failUnless( declarations.is_binary_operator( operator_pe ), 'operator+= should be idenitified as binray operator' )
Exemplo n.º 32
0
 def test_enum_patcher(self):
     fix_enum = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_enum' )
     self.failUnless( fix_enum, "Free function fix_enum has not been found." )
     self.failUnless( fix_enum.arguments[0].default_value == '::ns1::ns2::apple' )
Exemplo n.º 33
0
 def test_unnamed_enum_patcher(self):
     fix_unnamed = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_unnamed' )
     self.failUnless( fix_unnamed, "Free function fix_unnamed has not been found." )
     self.failUnless( fix_unnamed.arguments[0].default_value == u"int(::fx::unnamed)" )
Exemplo n.º 34
0
 def test_function_call_patcher(self):
     fix_function_call = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_function_call' )
     self.failUnless( fix_function_call, "Free function fix_function_call has not been found." )
     self.failUnless( fix_function_call.arguments[0].default_value == u"function_call::calc( 1, 2, 3 )" )
Exemplo n.º 35
0
 def test_fundamental_patcher(self):
     fcall = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_fundamental' )
     self.failUnless( fcall, "Free function fix_function_call has not been found." )
     self.failUnless( fcall.arguments[0].default_value == u"(unsigned int)(::fundamental::eggs)" )
Exemplo n.º 36
0
 def test_constructor_patcher(self):
     typedef__func = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='typedef__func' )
     self.failUnless( typedef__func, "Free function typedef__func has not been found." )
     self.failUnless( typedef__func.arguments[0].default_value == u"::typedef_::alias( )" )