diff --git a/test/Jamfile b/test/Jamfile index 55632135..cf118923 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -108,6 +108,7 @@ bpl-test crossmod_exception [ bpl-test exception_translator ] [ bpl-test pearu1 : test_cltree.py cltree.cpp ] [ bpl-test try : newtest.py m1.cpp m2.cpp ] +[ bpl-test const_argument ] [ bpl-test keywords : keywords.cpp keywords_test.py ] diff --git a/test/const_argument.cpp b/test/const_argument.cpp new file mode 100644 index 00000000..e40e0ed1 --- /dev/null +++ b/test/const_argument.cpp @@ -0,0 +1,30 @@ +/* Copyright 2004 Jonathan Brandmeyer + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + * The purpose of this test is to determine if a function can be called from + * Python with a const value type as an argument, and whether or not the + * presence of a prototype without the cv-qualifier will work around the + * compiler's bug. + */ +#include +using namespace boost::python; + +bool accept_const_arg_noproto( const object) +{ + return true; +} + +bool accept_const_arg_with_proto( object); +bool accept_const_arg_with_proto( const object) +{ + return true; +} + +BOOST_PYTHON_MODULE( const_argument_ext) +{ + def( "accept_const_arg_noproto", accept_const_arg_noproto); + def( "accept_const_arg_with_proto", accept_const_arg_with_proto); +} + diff --git a/test/const_argument.py b/test/const_argument.py new file mode 100644 index 00000000..2f1f4a06 --- /dev/null +++ b/test/const_argument.py @@ -0,0 +1,25 @@ +# Copyright Jonathan Brandmeyer, 2004. Distributed under the Boost +# Software License, Version 1.0 (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +""" +>>> from const_argument_ext import * +>>> accept_const_arg_noproto(1) +1 +>>> accept_const_arg_with_proto(1) +1 +""" + +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 + status = run()[0] + if (status == 0): print "Done." + sys.exit(status)