mirror of
https://github.com/boostorg/python.git
synced 2026-01-29 07:42:36 +00:00
This commit was manufactured by cvs2svn to create tag
'merged_to_RC_1_30_0'. [SVN r19627]
This commit is contained in:
@@ -124,8 +124,6 @@ bpl-test iterator : iterator.py iterator.cpp input_iterator.cpp ;
|
||||
|
||||
bpl-test extract ;
|
||||
|
||||
bpl-test opaque ;
|
||||
|
||||
bpl-test pickle1 ;
|
||||
bpl-test pickle2 ;
|
||||
bpl-test pickle3 ;
|
||||
|
||||
@@ -18,11 +18,7 @@ using namespace boost::python;
|
||||
|
||||
typedef test_class<> X;
|
||||
|
||||
struct Y : test_class<1>
|
||||
{
|
||||
Y(int v) : test_class<1>(v) {}
|
||||
Y& operator=(Y const& rhs) { x = rhs.x; return *this; }
|
||||
};
|
||||
typedef test_class<1> Y;
|
||||
|
||||
double get_fair_value(X const& x) { return x.value(); }
|
||||
|
||||
@@ -33,7 +29,6 @@ struct VarBase
|
||||
|
||||
std::string const name;
|
||||
std::string get_name1() const { return name; }
|
||||
|
||||
};
|
||||
|
||||
struct Var : VarBase
|
||||
@@ -43,14 +38,8 @@ struct Var : VarBase
|
||||
float value;
|
||||
char const* name2;
|
||||
Y y;
|
||||
|
||||
static int static1;
|
||||
static Y static2;
|
||||
};
|
||||
|
||||
int Var::static1 = 0;
|
||||
Y Var::static2(0);
|
||||
|
||||
BOOST_PYTHON_MODULE(data_members_ext)
|
||||
{
|
||||
class_<X>("X", init<int>())
|
||||
@@ -85,17 +74,6 @@ BOOST_PYTHON_MODULE(data_members_ext)
|
||||
.def("get_name2", &Var::get_name2, return_value_policy<return_by_value>())
|
||||
|
||||
.add_property("name3", &Var::get_name1)
|
||||
|
||||
// Test static data members
|
||||
.def_readonly("ro1a", &Var::static1)
|
||||
.def_readonly("ro1b", Var::static1)
|
||||
.def_readwrite("rw1a", &Var::static1)
|
||||
.def_readwrite("rw1b", Var::static1)
|
||||
|
||||
.def_readonly("ro2a", &Var::static2)
|
||||
.def_readonly("ro2b", Var::static2)
|
||||
.def_readwrite("rw2a", &Var::static2)
|
||||
.def_readwrite("rw2b", Var::static2)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,151 +1,6 @@
|
||||
'''
|
||||
>>> from data_members_ext import *
|
||||
|
||||
---- Test static data members ---
|
||||
|
||||
>>> v = Var('slim shady')
|
||||
|
||||
>>> Var.ro2a.x
|
||||
0
|
||||
>>> Var.ro2b.x
|
||||
0
|
||||
>>> Var.rw2a.x
|
||||
0
|
||||
>>> Var.rw2b.x
|
||||
0
|
||||
>>> v.ro2a.x
|
||||
0
|
||||
>>> v.ro2b.x
|
||||
0
|
||||
>>> v.rw2a.x
|
||||
0
|
||||
>>> v.rw2b.x
|
||||
0
|
||||
>>> Var.rw2a.x = 777
|
||||
>>> Var.ro2a.x
|
||||
777
|
||||
>>> Var.ro2b.x
|
||||
777
|
||||
>>> Var.rw2a.x
|
||||
777
|
||||
>>> Var.rw2b.x
|
||||
777
|
||||
>>> v.ro2a.x
|
||||
777
|
||||
>>> v.ro2b.x
|
||||
777
|
||||
>>> v.rw2a.x
|
||||
777
|
||||
>>> v.rw2b.x
|
||||
777
|
||||
>>> Var.rw2b = Y(888)
|
||||
>>> Var.ro2a.x
|
||||
888
|
||||
>>> Var.ro2b.x
|
||||
888
|
||||
>>> Var.rw2a.x
|
||||
888
|
||||
>>> Var.rw2b.x
|
||||
888
|
||||
>>> v.ro2a.x
|
||||
888
|
||||
>>> v.ro2b.x
|
||||
888
|
||||
>>> v.rw2a.x
|
||||
888
|
||||
>>> v.rw2b.x
|
||||
888
|
||||
>>> v.rw2b.x = 999
|
||||
>>> Var.ro2a.x
|
||||
999
|
||||
>>> Var.ro2b.x
|
||||
999
|
||||
>>> Var.rw2a.x
|
||||
999
|
||||
>>> Var.rw2b.x
|
||||
999
|
||||
>>> v.ro2a.x
|
||||
999
|
||||
>>> v.ro2b.x
|
||||
999
|
||||
>>> v.rw2a.x
|
||||
999
|
||||
>>> v.rw2b.x
|
||||
999
|
||||
|
||||
|
||||
>>> Var.ro1a
|
||||
0
|
||||
>>> Var.ro1b
|
||||
0
|
||||
>>> Var.rw1a
|
||||
0
|
||||
>>> Var.rw1b
|
||||
0
|
||||
>>> v.ro1a
|
||||
0
|
||||
>>> v.ro1b
|
||||
0
|
||||
>>> v.rw1a
|
||||
0
|
||||
>>> v.rw1b
|
||||
0
|
||||
>>> Var.rw1a = 777
|
||||
>>> Var.ro1a
|
||||
777
|
||||
>>> Var.ro1b
|
||||
777
|
||||
>>> Var.rw1a
|
||||
777
|
||||
>>> Var.rw1b
|
||||
777
|
||||
>>> v.ro1a
|
||||
777
|
||||
>>> v.ro1b
|
||||
777
|
||||
>>> v.rw1a
|
||||
777
|
||||
>>> v.rw1b
|
||||
777
|
||||
>>> Var.rw1b = 888
|
||||
>>> Var.ro1a
|
||||
888
|
||||
>>> Var.ro1b
|
||||
888
|
||||
>>> Var.rw1a
|
||||
888
|
||||
>>> Var.rw1b
|
||||
888
|
||||
>>> v.ro1a
|
||||
888
|
||||
>>> v.ro1b
|
||||
888
|
||||
>>> v.rw1a
|
||||
888
|
||||
>>> v.rw1b
|
||||
888
|
||||
>>> v.rw1b = 999
|
||||
>>> Var.ro1a
|
||||
999
|
||||
>>> Var.ro1b
|
||||
999
|
||||
>>> Var.rw1a
|
||||
999
|
||||
>>> Var.rw1b
|
||||
999
|
||||
>>> v.ro1a
|
||||
999
|
||||
>>> v.ro1b
|
||||
999
|
||||
>>> v.rw1a
|
||||
999
|
||||
>>> v.rw1b
|
||||
999
|
||||
|
||||
|
||||
|
||||
-----------------
|
||||
|
||||
>>> x = X(42)
|
||||
>>> x.x
|
||||
42
|
||||
@@ -184,7 +39,6 @@
|
||||
>>> v.name3
|
||||
'pi'
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def run(args = None):
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
# Copyright Gottfried Ganßauge 2003. 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.
|
||||
"""
|
||||
>>> from opaque_ext import *
|
||||
>>> #
|
||||
>>> # Check for correct conversion
|
||||
>>> use(get())
|
||||
|
||||
# Check that None is converted to a NULL opaque pointer
|
||||
>>> useany(get())
|
||||
1
|
||||
>>> useany(None)
|
||||
0
|
||||
|
||||
# check that we don't lose type information by converting NULL opaque
|
||||
# pointers to None
|
||||
>>> assert getnull() is None
|
||||
>>> useany(getnull())
|
||||
0
|
||||
|
||||
>>> failuse(get())
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
RuntimeError: success
|
||||
>>> #
|
||||
>>> # Check that there is no conversion from integers ...
|
||||
>>> use(0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: bad argument type for built-in operation
|
||||
>>> #
|
||||
>>> # ... and from strings to opaque objects
|
||||
>>> use("")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: bad argument type for built-in operation
|
||||
>>> #
|
||||
>>> # Now check the same for another opaque pointer type
|
||||
>>> use2(get2())
|
||||
>>> failuse2(get2())
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
RuntimeError: success
|
||||
>>> use2(0)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: bad argument type for built-in operation
|
||||
>>> use2("")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: bad argument type for built-in operation
|
||||
>>> #
|
||||
>>> # Check that opaque types are distinct
|
||||
>>> use(get2())
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: bad argument type for built-in operation
|
||||
>>> use2(get())
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: bad argument type for built-in operation
|
||||
"""
|
||||
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])
|
||||
Reference in New Issue
Block a user