[pygccxml-commit] source/pyplusplus/unittests regression3_tester.py,1.2,1.3
Brought to you by:
mbaas,
roman_yakovenko
From: Roman <rom...@us...> - 2006-03-05 05:50:28
|
Update of /cvsroot/pygccxml/source/pyplusplus/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18736/pyplusplus/unittests Modified Files: regression3_tester.py Log Message: pyplusplus now wraps hierarchy of abstract classes right. Next code will give you some idea: class base{ public: base(){} virtual ~base(){} virtual int get_value() const = 0; private: base( const base& ); base& operator=( const base& ); }; class middle : public base{ public: virtual void set_value(int) = 0; }; class final : public middle{ public: virtual int get_value() const{ return m_value; } virtual void set_value(int v){ m_value = v; } private: int m_value; }; Index: regression3_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/regression3_tester.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** regression3_tester.py 28 Feb 2006 07:31:33 -0000 1.2 --- regression3_tester.py 5 Mar 2006 05:50:25 -0000 1.3 *************** *** 20,33 **** , *args ) def run_tests(self, module): ! self.fail( "For this test pyplusplus should generate invalid code") ! ! def test( self ): ! try: ! super(tester_t, self).test() ! self.fail( "For this test pyplusplus should generate invalid code" ) ! except RuntimeError: ! pass def create_suite(): suite = unittest.TestSuite() --- 20,52 ---- , *args ) + def create_python_final(self, class_ ): + class tester_impl_t( class_ ): + def __init__(self): + class_.__init__( self ) + self.value = 21 + + def get_value(self): + return self.value + + def set_value( self, i ): + self.value = i + + return tester_impl_t() + def run_tests(self, module): ! final_inst = module.final() ! final_inst.set_value( -2 ) ! self.failUnless( module.get_value( final_inst ) == -2 ) ! self.failUnless( final_inst.get_value() == -2 ) + inst = self.create_python_final( module.middle ) + self.failUnless( module.get_value( inst ) == 21 ) + self.failUnless( inst.get_value() == 21 ) + inst.set_value( -2 ) + self.failUnless( module.get_value( inst ) == -2 ) + self.failUnless( inst.get_value() == -2 ) + + + def create_suite(): suite = unittest.TestSuite() |