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) 4from __future__ import print_function 5''' 6>>> from iterator_ext import * 7>>> from input_iterator import * 8>>> x = list_int() 9>>> x.push_back(1) 10>>> x.back() 111 12>>> x.push_back(3) 13>>> x.push_back(5) 14>>> for y in x: 15... print(y) 161 173 185 19>>> z = range(x) 20>>> for y in z: 21... print(y) 221 233 245 25 26 Range2 wraps a transform_iterator which doubles the elements it 27 traverses. This proves we can wrap input iterators 28 29>>> z2 = range2(x) 30>>> for y in z2: 31... print(y) 322 336 3410 35 36>>> l2 = two_lists() 37>>> for y in l2.primes: 38... print(y) 392 403 415 427 4311 4413 45>>> for y in l2.evens: 46... print(y) 472 484 496 508 5110 5212 53>>> ll = list_list() 54>>> ll.push_back(x) 55>>> x.push_back(7) 56>>> ll.push_back(x) 57>>> for a in ll: #doctest: +NORMALIZE_WHITESPACE 58... for b in a: 59... print(b, end='') 60... print('') 61... 621 3 5 631 3 5 7 64''' 65def run(args = None): 66 import sys 67 import doctest 68 69 if args is not None: 70 sys.argv = args 71 return doctest.testmod(sys.modules.get(__name__)) 72 73if __name__ == '__main__': 74 print("running...") 75 import sys 76 status = run()[0] 77 if (status == 0): print("Done.") 78 sys.exit(status) 79