mirror of
https://github.com/boostorg/python.git
synced 2026-01-24 18:12:43 +00:00
- Added a new test exercising the new automatic inheritation
[SVN r18815]
This commit is contained in:
@@ -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'
|
||||
|
||||
27
pyste/tests/inherit2.h
Normal file
27
pyste/tests/inherit2.h
Normal file
@@ -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; }
|
||||
};
|
||||
|
||||
}
|
||||
2
pyste/tests/inherit2.pyste
Normal file
2
pyste/tests/inherit2.pyste
Normal file
@@ -0,0 +1,2 @@
|
||||
Class('inherit2::B', 'inherit2.h')
|
||||
Class('inherit2::D', 'inherit2.h')
|
||||
25
pyste/tests/inherit2UT.py
Normal file
25
pyste/tests/inherit2UT.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user