Skip to content

Commit 6158084

Browse files
author
roman_yakovenko
committed
few bug fixes, after upgrading to latest gccxml version
1 parent b738d9f commit 6158084

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

unittests/filters_tester.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,33 @@
1313
from pygccxml import declarations
1414

1515
class tester_t( parser_test_case.parser_test_case_t ):
16+
global_ns = None
1617
COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE
1718
def __init__(self, *args ):
1819
parser_test_case.parser_test_case_t.__init__( self, *args )
1920
self.header = 'declarations_calldef.hpp'
20-
self.declarations = None
21+
self.global_ns = None
2122

2223
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
2529

30+
2631
def test_regex( self ):
2732
criteria = declarations.regex_matcher_t( 'oper.*'
2833
, 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 )
3036
self.failUnless( 6 == len(operators) )
3137

3238
def test_access_type( self ):
3339
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 )
3541
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 )
3743
self.failUnless( 16 == len( public_members ) )
3844
else:
3945
self.failUnless( 20 == len( public_members ) )
@@ -42,10 +48,10 @@ def test_or_matcher( self ):
4248
criteria1 = declarations.regex_matcher_t( 'oper.*'
4349
, lambda decl: decl.name )
4450
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 )
4652

4753
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 )
4955
self.failUnless( 15 <= len( found ) <= 21)
5056
else:
5157
self.failUnless( 19 <= len( found ) <= 25)
@@ -54,13 +60,15 @@ def test_and_matcher( self ):
5460
criteria1 = declarations.regex_matcher_t( 'oper.*'
5561
, lambda decl: decl.name )
5662
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 )
5865
self.failUnless( len( found ) <= 6 )
5966

6067
def test_not_matcher( self ):
6168
criteria1 = declarations.regex_matcher_t( 'oper.*'
6269
, 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 )
6472
self.failUnless( len( found ) == 6 )
6573

6674
def create_suite():

0 commit comments

Comments
 (0)