From 73e2ab5125f0e780b50385ba049449134da8d40d Mon Sep 17 00:00:00 2001 From: Bruno da Silva de Oliveira Date: Tue, 17 Jun 2003 01:56:45 +0000 Subject: [PATCH] - Added a new test exercising the new automatic inheritation [SVN r18815] --- pyste/src/pyste.py | 2 +- pyste/tests/inherit2.h | 27 +++++++++++++++++++++++++++ pyste/tests/inherit2.pyste | 2 ++ pyste/tests/inherit2UT.py | 25 +++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 pyste/tests/inherit2.h create mode 100644 pyste/tests/inherit2.pyste create mode 100644 pyste/tests/inherit2UT.py diff --git a/pyste/src/pyste.py b/pyste/src/pyste.py index cbb0090d..58910f43 100644 --- a/pyste/src/pyste.py +++ b/pyste/src/pyste.py @@ -39,7 +39,7 @@ from policies import * from CppParser import CppParser, CppParserError import time -__VERSION__ = '0.9.3' +__VERSION__ = '0.9.4' def RecursiveIncludes(include): 'Return a list containg the include dir and all its subdirectories' diff --git a/pyste/tests/inherit2.h b/pyste/tests/inherit2.h new file mode 100644 index 00000000..40aed2f2 --- /dev/null +++ b/pyste/tests/inherit2.h @@ -0,0 +1,27 @@ +namespace inherit2 { + +struct A +{ + int x; + int getx() { return x; } +}; + +struct B : A +{ + int y; + int gety() { return y; } +}; + +struct C : B +{ + int z; + int getz() { return z; } +}; + +struct D : C +{ + int w; + int getw() { return w; } +}; + +} diff --git a/pyste/tests/inherit2.pyste b/pyste/tests/inherit2.pyste new file mode 100644 index 00000000..38082139 --- /dev/null +++ b/pyste/tests/inherit2.pyste @@ -0,0 +1,2 @@ +Class('inherit2::B', 'inherit2.h') +Class('inherit2::D', 'inherit2.h') diff --git a/pyste/tests/inherit2UT.py b/pyste/tests/inherit2UT.py new file mode 100644 index 00000000..1ca08705 --- /dev/null +++ b/pyste/tests/inherit2UT.py @@ -0,0 +1,25 @@ +import unittest +from _inherit2 import * + +class InheritExampleTest(unittest.TestCase): + + def testIt(self): + b = B() + d = D() + + self.assert_(issubclass(D, B)) + b.x, b.y = 10, 5 + self.assertEqual(b.getx(), 10) + self.assertEqual(b.gety(), 5) + d.x, d.y, d.z, d.w = 20, 15, 10, 5 + self.assertEqual(d.getx(), 20) + self.assertEqual(d.gety(), 15) + self.assertEqual(d.getz(), 10) + self.assertEqual(d.getw(), 5) + + def wrong(): + return b.getw() + self.assertRaises(AttributeError, wrong) + +if __name__ == '__main__': + unittest.main()