]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/slice.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / python / test / slice.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 slice_ext import *
6 >>> accept_slice(slice(1, None, (1,2)))
7 1
8 >>> try:
9 ... accept_slice(list((1,2)))
10 ... print("test failed")
11 ... except:
12 ... print("test passed")
13 ...
14 test passed
15 >>> try:
16 ... from Numeric import array
17 ... except:
18 ... print(1)
19 ... else:
20 ... check_numeric_array_rich_slice('Numeric', 'ArrayType', lambda x:x)
21 ...
22 1
23 >>> try:
24 ... from numarray import array, all
25 ... except:
26 ... print(1)
27 ... else:
28 ... check_numeric_array_rich_slice('numarray', 'NDArray', all)
29 ...
30 1
31 >>> import sys
32 >>> if sys.version_info[0] == 2 and sys.version_info[1] >= 3:
33 ... check_string_rich_slice()
34 ... elif sys.version_info[0] > 2:
35 ... check_string_rich_slice()
36 ... else:
37 ... print(1)
38 ...
39 1
40 >>> check_slice_get_indices( slice(None))
41 0
42 >>> check_slice_get_indices( slice(2,-2))
43 0
44 >>> check_slice_get_indices( slice(2, None, 2))
45 5
46 >>> check_slice_get_indices( slice(2, None, -1))
47 -12
48 >>> check_slice_get_indices( slice( 20, None))
49 0
50 >>> check_slice_get_indices( slice( -2, -5, -2))
51 6
52 """
53
54 # Performs an affirmative and negative argument resolution check,
55 # checks the operation of extended slicing in Numeric arrays
56 # (only performed if Numeric.array or numarray.array can be found).
57 # checks the operation of extended slicing in new strings (Python 2.3 only).
58
59 def run(args = None):
60 import sys
61 import doctest
62
63 if args is not None:
64 sys.argv = args
65 return doctest.testmod(sys.modules.get(__name__))
66
67 if __name__ == '__main__':
68 print("running...")
69 import sys
70 status = run()[0]
71 if (status == 0): print("Done.")
72 sys.exit(status)