Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

updated boost from 1_33_1 to 1_34_1

File size: 1.1 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 operators_ext import *
6
7  Check __nonzero__ support
8 
9>>> assert X(2)
10>>> assert not X(0)
11
12 ----
13 
14>>> x = X(42)
15>>> x.value()
1642
17>>> y = x - X(5)
18>>> y.value()
1937
20>>> y = x - 4
21>>> y.value()
2238
23>>> y = 3 - x
24>>> y.value()
25-39
26>>> (-y).value()
2739
28
29>>> (x + y).value()
303
31
32>>> abs(y).value()
3339
34
35>>> x < 10
360
37>>> x < 43
381
39
40>>> 10 < x
411
42>>> 43 < x
430
44
45>>> x < y
460
47>>> y < x
481
49
50 ------
51>>> x > 10
521
53>>> x > 43
540
55
56>>> 10 > x
570
58>>> 43 > x
591
60
61>>> x > y
621
63>>> y > x
640
65
66>>> y = x - 5
67>>> x -= y
68>>> x.value()
695
70>>> str(x)
71'5'
72
73>>> z = Z(10)
74>>> int(z)
7510
76>>> float(z)
7710.0
78>>> complex(z)
79(10+0j)
80
81>>> pow(2,x)
8232
83>>> pow(x,2).value()
8425
85>>> pow(X(2),x).value()
8632
87'''
88
89def run(args = None):
90    import sys
91    import doctest
92
93    if args is not None:
94        sys.argv = args
95    return doctest.testmod(sys.modules.get(__name__))
96   
97if __name__ == '__main__':
98    print "running..."
99    import sys
100    status = run()[0]
101    if (status == 0): print "Done."
102    sys.exit(status)
Note: See TracBrowser for help on using the repository browser.