]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/auto_ptr.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / python / test / auto_ptr.py
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()
8 42
9 >>> look(x), look(x)
10 (42, 42)
11
12 >>> maybe_steal(x, 0)
13 42
14 >>> look(x)
15 42
16
17 >>> maybe_steal(x, 1)
18 42
19 >>> broken_auto_ptr and -1 or look(x)
20 -1
21
22 >>> x = X(69)
23 >>> steal(x)
24 69
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)
35 77
36
37 >>> z = callback(lambda z: z)
38 >>> z.value()
39 77
40
41 >>> extract(x).value()
42 77
43
44 #
45 # Test derived to base conversions
46 #
47
48 >>> y = Y(42)
49 >>> y.value()
50 42
51
52 >>> try: maybe_steal(y, 0)
53 ... except TypeError: pass
54 ... else: print('expected a TypeError exception')
55
56 >>> y.value()
57 42
58
59 >>> broken_auto_ptr and 42 or steal(y)
60 42
61
62 >>> if not broken_auto_ptr:
63 ... try: y.value()
64 ... except TypeError: pass
65 ... else: print('expected a TypeError exception')
66
67 >>> print(look.__doc__.splitlines()[1])
68 look( (X)arg1) -> int :
69
70 >>> print(steal.__doc__.splitlines()[1])
71 steal( (X)arg1) -> int :
72
73 >>> print(maybe_steal.__doc__.splitlines()[1])
74 maybe_steal( (X)arg1, (bool)arg2) -> int :
75
76 >>> print(make.__doc__.splitlines()[1])
77 make() -> X :
78
79 >>> print(callback.__doc__.splitlines()[1])
80 callback( (object)arg1) -> X :
81
82 >>> print(extract.__doc__.splitlines()[1])
83 extract( (object)arg1) -> X :
84
85 '''
86
87 def run(args = None):
88 import sys
89 import doctest
90
91 if args is not None:
92 sys.argv = args
93 return doctest.testmod(sys.modules.get(__name__))
94
95 if __name__ == '__main__':
96 print("running...")
97 import sys
98 status = run()[0]
99 if (status == 0): print("Done.")
100 sys.exit(status)