Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/auto_ptr.py @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.4 KB
Line 
1# Copyright David Abrahams 2004. Distributed under the Boost
2# Software License, Version 1.0. (See accompanying
3# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4'''
5>>> from auto_ptr_ext import *
6>>> x = X(42)
7>>> x.value()
842
9>>> look(x), look(x)
10(42, 42)
11
12>>> maybe_steal(x, 0)
1342
14>>> look(x)
1542
16
17>>> maybe_steal(x, 1)
1842
19>>> broken_auto_ptr and -1 or look(x)
20-1
21
22>>> x = X(69)
23>>> steal(x)
2469
25>>> broken_auto_ptr and -1 or look(x)
26-1
27
28>>> if not broken_auto_ptr:
29...     try: x.value()
30...     except TypeError: pass
31...     else: print 'expected a TypeError exception'
32
33>>> x = make()
34>>> look(x)
3577
36
37>>> z = callback(lambda z: z)
38>>> z.value()
3977
40
41>>> extract(x).value()
4277
43
44#
45# Test derived to base conversions
46#
47
48>>> y = Y(42)
49>>> y.value()
5042
51
52>>> try: maybe_steal(y, 0)
53... except TypeError: pass
54... else: print 'expected a TypeError exception'
55
56>>> y.value()
5742
58
59>>> broken_auto_ptr and 42 or steal(y)
6042
61
62>>> if not broken_auto_ptr:
63...     try: y.value()
64...     except TypeError: pass
65...     else: print 'expected a TypeError exception'
66
67'''
68
69def run(args = None):
70    import sys
71    import doctest
72
73    if args is not None:
74        sys.argv = args
75    return doctest.testmod(sys.modules.get(__name__))
76   
77if __name__ == '__main__':
78    print "running..."
79    import sys
80    status = run()[0]
81    if (status == 0): print "Done."
82    sys.exit(status)
Note: See TracBrowser for help on using the repository browser.