2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Another way to break the lib from Peter Bienstman

[SVN r13410]
This commit is contained in:
Dave Abrahams
2002-04-09 14:48:23 +00:00
parent 9137b38fb9
commit 79f8f3eb14
3 changed files with 57 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ rule bpl-test ( name ? : files * )
bpl-test bienstman1 ;
bpl-test bienstman2 ;
bpl-test bienstman3 ;
bpl-test bienstman4 ;
bpl-test try : newtest.py m1.cpp m2.cpp ;
bpl-test builtin_converters : test_builtin_converters.py test_builtin_converters.cpp ;
bpl-test test_pointer_adoption ;

38
test/bienstman4.cpp Normal file
View File

@@ -0,0 +1,38 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#include <boost/python/implicit.hpp>
#include <boost/mpl/type_list.hpp>
struct T1 {};
struct Term {Term(T1 const&) {} };
struct Expression {void add(Term const&) {} };
BOOST_PYTHON_MODULE_INIT(bienstman4_ext)
{
using namespace boost::python;
using boost::mpl::type_list;
implicitly_convertible<T1,Term>();
module("bienstman4_ext")
.add(class_<Expression>("Expression")
.def("add", &Expression::add))
.add(class_<T1>("T1"))
.add(class_<Term>("Term")
.def_init(type_list<T1&>()))
;
T1 t1;
Expression e;
e.add(t1);
}

18
test/bienstman4.py Normal file
View File

@@ -0,0 +1,18 @@
'''
>>> from bienstman4_ext import *
>>> t1 = T1()
>>> e = Expression()
>>> e.add(t1)
'''
def run(args = None):
import sys
import doctest
if args is not None:
sys.argv = args
return doctest.testmod(sys.modules.get(__name__))
if __name__ == '__main__':
print "running..."
import sys
sys.exit(run()[0])