Skip to content

Commit ef05b5c

Browse files
author
roman_yakovenko
committed
add tester for gccxml 10185 issue
1 parent 379278e commit ef05b5c

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

unittests/gccxml10185_tester.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2004-2008 Roman Yakovenko.
2+
# Distributed under the Boost Software License, Version 1.0. (See
3+
# accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
import os
7+
import unittest
8+
import autoconfig
9+
import parser_test_case
10+
11+
from pygccxml import utils
12+
from pygccxml import parser
13+
from pygccxml import declarations
14+
15+
code = \
16+
"""
17+
template <typename T> struct A {};
18+
template <int N> struct A<const char[N]>
19+
{ static int size(const char[N]) { return N - 1; } };
20+
"""
21+
22+
class tester_t( parser_test_case.parser_test_case_t ):
23+
def __init__(self, *args):
24+
parser_test_case.parser_test_case_t.__init__(self, *args)
25+
26+
def test(self):
27+
src_reader = parser.source_reader_t( self.config )
28+
global_ns = declarations.get_global_namespace( src_reader.read_string( code ) )
29+
a = global_ns.class_( 'A<const char [N]>' )
30+
size = a.mem_fun( 'size' )
31+
32+
33+
def create_suite():
34+
suite = unittest.TestSuite()
35+
suite.addTest( unittest.makeSuite(tester_t))
36+
return suite
37+
38+
def run_suite():
39+
unittest.TextTestRunner(verbosity=2).run( create_suite() )
40+
41+
if __name__ == "__main__":
42+
run_suite()

unittests/test_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import calling_convention_tester
5656
import const_volatile_arg_tester
5757
import array_bug_tester
58+
import gccxml10185_tester
5859

5960
testers = [
6061
decl_string_tester
@@ -106,6 +107,7 @@
106107
, calling_convention_tester
107108
, const_volatile_arg_tester
108109
, array_bug_tester
110+
, gccxml10185_tester
109111
]
110112

111113
def create_suite():

unittests/type_as_exception_bug_tester.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ def setUp(self):
2424
tester_t.global_ns.init_optimizer()
2525

2626
def test( self ):
27-
pass
28-
#~ buggy = self.global_ns.mem_fun( 'buggy' )
29-
#~ ExpressionError = self.global_ns.class_( 'ExpressionError' )
30-
#~ self.failUnless( len( buggy.exceptions ) == 1 )
31-
#~ err = buggy.exceptions[0]
32-
#~ self.failUnless( declarations.is_reference( err ) )
33-
#~ err = declarations.remove_declarated( declarations.remove_reference( err ) )
34-
#~ self.failUnless( err is ExpressionError )
27+
buggy = self.global_ns.mem_fun( 'buggy' )
28+
ExpressionError = self.global_ns.class_( 'ExpressionError' )
29+
self.failUnless( len( buggy.exceptions ) == 1 )
30+
err = buggy.exceptions[0]
31+
self.failUnless( declarations.is_reference( err ) )
32+
err = declarations.remove_declarated( declarations.remove_reference( err ) )
33+
self.failUnless( err is ExpressionError )
3534

3635

3736
def create_suite():

0 commit comments

Comments
 (0)