2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 05:42:30 +00:00

support for data members

[SVN r13309]
This commit is contained in:
Dave Abrahams
2002-03-30 01:23:28 +00:00
parent 4a81d366bb
commit 7ffc983edd
5 changed files with 98 additions and 13 deletions

View File

@@ -58,6 +58,7 @@ bpl-test callbacks ;
bpl-test virtual_functions ;
bpl-test back_reference ;
bpl-test implicit ;
bpl-test data_members ;
# --- unit tests of library components ---
unit-test indirect_traits_test

29
test/data_members.py Normal file
View File

@@ -0,0 +1,29 @@
'''
>>> from data_members_ext import *
>>> x = X(42)
>>> x.x
42
>>> try: x.x = 77
>>> except AttributeError: pass
>>> else: print 'no error'
>>> y = Y(69)
>>> y.x
69
>>> y.x = 77
>>> y.x
77
'''
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])

View File

@@ -18,12 +18,13 @@ struct test_class
int value() const { assert(magic == 7654321 + n); return x; }
operator int() const { return x; }
static int count() { return counter; }
private:
void operator=(test_class const&);
private:
int x;
long magic;
static int counter;
private:
void operator=(test_class const&);
};
template <int n>