back_reference.py 798 B

12345678910111213141516171819202122232425262728293031323334353637
  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 back_reference_ext import *
  6. >>> y = Y(3)
  7. >>> z = Z(4)
  8. >>> x_instances()
  9. 2
  10. >>> y2 = copy_Y(y)
  11. >>> x_instances()
  12. 3
  13. >>> z2 = copy_Z(z)
  14. >>> x_instances()
  15. 4
  16. >>> assert y_identity(y) is y
  17. >>> y_equality(y, y)
  18. 1
  19. >>> print(y_identity.__doc__.splitlines()[1])
  20. y_identity( (Y)arg1) -> object :
  21. '''
  22. def run(args = None):
  23. import sys
  24. import doctest
  25. if args is not None:
  26. sys.argv = args
  27. return doctest.testmod(sys.modules.get(__name__))
  28. if __name__ == '__main__':
  29. print("running...")
  30. import sys
  31. status = run()[0]
  32. if (status == 0): print("Done.")
  33. sys.exit(status)