Skip to content

Commit 5309573

Browse files
EricCousineau-TRIwjakob
authored andcommitted
operators: Move hash check to before mutations, tweak whitespace
1 parent 2c30e0a commit 5309573

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

tests/test_operator_overloading.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def test_operator_overloading():
2424
assert str(v1 * v2) == "[3.000000, -2.000000]"
2525
assert str(v2 / v1) == "[3.000000, -0.500000]"
2626

27+
assert hash(v1) == 4
28+
2729
v1 += 2 * v2
2830
assert str(v1) == "[7.000000, 0.000000]"
2931
v1 -= v2
@@ -37,22 +39,30 @@ def test_operator_overloading():
3739
v2 /= v1
3840
assert str(v2) == "[2.000000, 8.000000]"
3941

40-
assert hash(v1) == 4
41-
4242
cstats = ConstructorStats.get(m.Vector2)
4343
assert cstats.alive() == 2
4444
del v1
4545
assert cstats.alive() == 1
4646
del v2
4747
assert cstats.alive() == 0
48-
assert cstats.values() == ['[1.000000, 2.000000]', '[3.000000, -1.000000]',
49-
'[-3.000000, 1.000000]', '[4.000000, 1.000000]',
50-
'[-2.000000, 3.000000]', '[-7.000000, -6.000000]',
51-
'[9.000000, 10.000000]', '[8.000000, 16.000000]',
52-
'[0.125000, 0.250000]', '[7.000000, 6.000000]',
53-
'[9.000000, 10.000000]', '[8.000000, 16.000000]',
54-
'[8.000000, 4.000000]', '[3.000000, -2.000000]',
55-
'[3.000000, -0.500000]', '[6.000000, -2.000000]']
48+
assert cstats.values() == [
49+
'[1.000000, 2.000000]',
50+
'[3.000000, -1.000000]',
51+
'[-3.000000, 1.000000]',
52+
'[4.000000, 1.000000]',
53+
'[-2.000000, 3.000000]',
54+
'[-7.000000, -6.000000]',
55+
'[9.000000, 10.000000]',
56+
'[8.000000, 16.000000]',
57+
'[0.125000, 0.250000]',
58+
'[7.000000, 6.000000]',
59+
'[9.000000, 10.000000]',
60+
'[8.000000, 16.000000]',
61+
'[8.000000, 4.000000]',
62+
'[3.000000, -2.000000]',
63+
'[3.000000, -0.500000]',
64+
'[6.000000, -2.000000]',
65+
]
5666
assert cstats.default_constructions == 0
5767
assert cstats.copy_constructions == 0
5868
assert cstats.move_constructions >= 10

0 commit comments

Comments
 (0)