13
13
from pygccxml import declarations
14
14
15
15
class tester_t ( parser_test_case .parser_test_case_t ):
16
+ global_ns = None
16
17
COMPILATION_MODE = parser .COMPILATION_MODE .ALL_AT_ONCE
17
18
def __init__ (self , * args ):
18
19
parser_test_case .parser_test_case_t .__init__ ( self , * args )
19
20
self .header = 'declarations_calldef.hpp'
20
- self .declarations = None
21
+ self .global_ns = None
21
22
22
23
def setUp (self ):
23
- if not self .declarations :
24
- self .declarations = parser .parse ( [self .header ], self .config )
24
+ if not tester_t .global_ns :
25
+ decls = parser .parse ( [self .header ], self .config )
26
+ tester_t .global_ns = declarations .get_global_namespace ( decls )
27
+ tester_t .global_ns .init_optimizer ()
28
+ self .global_ns = tester_t .global_ns
25
29
30
+
26
31
def test_regex ( self ):
27
32
criteria = declarations .regex_matcher_t ( 'oper.*'
28
33
, lambda decl : decl .name )
29
- operators = declarations .matcher .find ( criteria , self .declarations )
34
+ operators = declarations .matcher .find ( criteria , self .global_ns )
35
+ operators = filter ( lambda d : not d .is_artificial , operators )
30
36
self .failUnless ( 6 == len (operators ) )
31
37
32
38
def test_access_type ( self ):
33
39
criteria = declarations .access_type_matcher_t ( declarations .ACCESS_TYPES .PUBLIC )
34
- public_members = declarations .matcher .find ( criteria , self .declarations )
40
+ public_members = declarations .matcher .find ( criteria , self .global_ns )
35
41
if '0.9' in public_members [0 ].compiler :
36
- #2 empty classes, this compiler doesn't generate constructor and copy constructor
42
+ public_members = filter ( lambda d : not d . is_artificial , public_members )
37
43
self .failUnless ( 16 == len ( public_members ) )
38
44
else :
39
45
self .failUnless ( 20 == len ( public_members ) )
@@ -42,10 +48,10 @@ def test_or_matcher( self ):
42
48
criteria1 = declarations .regex_matcher_t ( 'oper.*'
43
49
, lambda decl : decl .name )
44
50
criteria2 = declarations .access_type_matcher_t ( declarations .ACCESS_TYPES .PUBLIC )
45
- found = declarations .matcher .find ( criteria1 | criteria2 , self .declarations )
51
+ found = declarations .matcher .find ( criteria1 | criteria2 , self .global_ns )
46
52
47
53
if '0.9' in found [0 ].compiler :
48
- #2 empty classes, this compiler doesn't generate constructor and copy constructor
54
+ found = filter ( lambda d : not d . is_artificial , found )
49
55
self .failUnless ( 15 <= len ( found ) <= 21 )
50
56
else :
51
57
self .failUnless ( 19 <= len ( found ) <= 25 )
@@ -54,13 +60,15 @@ def test_and_matcher( self ):
54
60
criteria1 = declarations .regex_matcher_t ( 'oper.*'
55
61
, lambda decl : decl .name )
56
62
criteria2 = declarations .access_type_matcher_t ( declarations .ACCESS_TYPES .PUBLIC )
57
- found = declarations .matcher .find ( criteria1 & criteria2 , self .declarations )
63
+ found = declarations .matcher .find ( criteria1 & criteria2 , self .global_ns )
64
+ found = filter ( lambda d : not d .is_artificial , found )
58
65
self .failUnless ( len ( found ) <= 6 )
59
66
60
67
def test_not_matcher ( self ):
61
68
criteria1 = declarations .regex_matcher_t ( 'oper.*'
62
69
, lambda decl : decl .name )
63
- found = declarations .matcher .find ( ~ ( ~ criteria1 ), self .declarations )
70
+ found = declarations .matcher .find ( ~ ( ~ criteria1 ), self .global_ns )
71
+ found = filter ( lambda d : not d .is_artificial , found )
64
72
self .failUnless ( len ( found ) == 6 )
65
73
66
74
def create_suite ():
0 commit comments