-
Notifications
You must be signed in to change notification settings - Fork 42
/
type_as_exception_bug_tester.py
47 lines (35 loc) · 1.37 KB
/
type_as_exception_bug_tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright 2014-2016 Insight Software Consortium.
# Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt
import unittest
import parser_test_case
from pygccxml import parser
from pygccxml import declarations
class Test(parser_test_case.parser_test_case_t):
global_ns = None
def __init__(self, *args):
parser_test_case.parser_test_case_t.__init__(self, *args)
self.header = 'type_as_exception_bug.h'
def setUp(self):
if not Test.global_ns:
decls = parser.parse([self.header], self.config)
Test.global_ns = declarations.get_global_namespace(decls)
Test.global_ns.init_optimizer()
def test(self):
buggy = self.global_ns.mem_fun('buggy')
expression_error = self.global_ns.class_('ExpressionError')
self.assertTrue(len(buggy.exceptions) == 1)
err = buggy.exceptions[0]
self.assertTrue(declarations.is_reference(err))
err = declarations.remove_declarated(
declarations.remove_reference(err))
self.assertTrue(err is expression_error)
def create_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Test))
return suite
def run_suite():
unittest.TextTestRunner(verbosity=2).run(create_suite())
if __name__ == "__main__":
run_suite()