Wenzel Jakob | 5708221 | 2015-09-04 23:42:12 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | from __future__ import print_function |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 3 | import sys |
| 4 | sys.path.append('.') |
| 5 | |
| 6 | from example import Vector2, Vector |
| 7 | |
| 8 | v1 = Vector2(1, 2) |
| 9 | v2 = Vector(3, -1) |
| 10 | |
| 11 | print("v1 = " + str(v1)) |
| 12 | print("v2 = " + str(v2)) |
| 13 | print("v1+v2 = " + str(v1+v2)) |
| 14 | print("v1-v2 = " + str(v1-v2)) |
| 15 | print("v1-8 = " + str(v1-8)) |
| 16 | print("v1+8 = " + str(v1+8)) |
| 17 | print("v1*8 = " + str(v1*8)) |
| 18 | print("v1/8 = " + str(v1/8)) |
Wenzel Jakob | 73a50a0 | 2015-09-11 17:09:47 +0200 | [diff] [blame] | 19 | print("8-v1 = " + str(8-v1)) |
| 20 | print("8+v1 = " + str(8+v1)) |
| 21 | print("8*v1 = " + str(8*v1)) |
| 22 | print("8/v1 = " + str(8/v1)) |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 23 | |
| 24 | v1 += v2 |
| 25 | v1 *= 2 |
| 26 | |
| 27 | print("(v1+v2)*2 = " + str(v1)) |
Jason Rhinelander | 3f58937 | 2016-08-07 13:05:26 -0400 | [diff] [blame] | 28 | |
| 29 | from example import ConstructorStats |
| 30 | cstats = ConstructorStats.get(Vector2) |
| 31 | print("Instances not destroyed:", cstats.alive()) |
| 32 | v1 = None |
| 33 | print("Instances not destroyed:", cstats.alive()) |
| 34 | v2 = None |
| 35 | print("Instances not destroyed:", cstats.alive()) |
| 36 | print("Constructor values:", cstats.values()) |
| 37 | print("Default constructions:", cstats.default_constructions) |
| 38 | print("Copy constructions:", cstats.copy_constructions) |
| 39 | print("Move constructions:", cstats.move_constructions >= 10) |
| 40 | print("Copy assignments:", cstats.copy_assignments) |
| 41 | print("Move assignments:", cstats.move_assignments) |