3 from pybind11_tests
import ConstructorStats
4 from pybind11_tests
import operators
as m
13 assert str(v1) ==
"[1.000000, 2.000000]" 14 assert str(v2) ==
"[3.000000, -1.000000]" 16 assert str(-v2) ==
"[-3.000000, 1.000000]" 18 assert str(v1 + v2) ==
"[4.000000, 1.000000]" 19 assert str(v1 - v2) ==
"[-2.000000, 3.000000]" 20 assert str(v1 - 8) ==
"[-7.000000, -6.000000]" 21 assert str(v1 + 8) ==
"[9.000000, 10.000000]" 22 assert str(v1 * 8) ==
"[8.000000, 16.000000]" 23 assert str(v1 / 8) ==
"[0.125000, 0.250000]" 24 assert str(8 - v1) ==
"[7.000000, 6.000000]" 25 assert str(8 + v1) ==
"[9.000000, 10.000000]" 26 assert str(8 * v1) ==
"[8.000000, 16.000000]" 27 assert str(8 / v1) ==
"[8.000000, 4.000000]" 28 assert str(v1 * v2) ==
"[3.000000, -2.000000]" 29 assert str(v2 / v1) ==
"[3.000000, -0.500000]" 38 assert str(v1) ==
"[7.000000, 0.000000]" 40 assert str(v1) ==
"[4.000000, 1.000000]" 42 assert str(v1) ==
"[8.000000, 2.000000]" 44 assert str(v1) ==
"[0.500000, 0.125000]" 46 assert str(v1) ==
"[1.500000, -0.125000]" 48 assert str(v2) ==
"[2.000000, 8.000000]" 51 assert cstats.alive() == 3
53 assert cstats.alive() == 2
55 assert cstats.alive() == 1
57 assert cstats.alive() == 0
58 assert cstats.values() == [
59 "[1.000000, 2.000000]",
60 "[3.000000, -1.000000]",
61 "[1.000000, 2.000000]",
62 "[-3.000000, 1.000000]",
63 "[4.000000, 1.000000]",
64 "[-2.000000, 3.000000]",
65 "[-7.000000, -6.000000]",
66 "[9.000000, 10.000000]",
67 "[8.000000, 16.000000]",
68 "[0.125000, 0.250000]",
69 "[7.000000, 6.000000]",
70 "[9.000000, 10.000000]",
71 "[8.000000, 16.000000]",
72 "[8.000000, 4.000000]",
73 "[3.000000, -2.000000]",
74 "[3.000000, -0.500000]",
75 "[6.000000, -2.000000]",
77 assert cstats.default_constructions == 0
78 assert cstats.copy_constructions == 0
79 assert cstats.move_constructions >= 10
80 assert cstats.copy_assignments == 0
81 assert cstats.move_assignments == 0
85 """#393: need to return NotSupported to ensure correct arithmetic operator behavior""" 87 c1, c2 = m.C1(), m.C2()
95 """#328: first member in a class can't be used in operators""" 102 assert m.get_NestA(a) == 13
104 assert m.get_NestA(b.a) == 103
106 assert m.get_NestA(c.b.a) == 1003
108 assert m.get_NestB(b) == 3
110 assert m.get_NestB(c.b) == 1
112 assert m.get_NestC(c) == 35
115 assert abase.value == -2
116 a.as_base().value += 44
117 assert abase.value == 42
118 assert c.b.a.as_base().value == -2
119 c.b.a.as_base().value += 44
120 assert c.b.a.as_base().value == 42
127 assert abase.value == 42
134 assert m.Comparable(15)
is not m.Comparable(15)
135 assert m.Comparable(15) == m.Comparable(15)
137 with pytest.raises(TypeError)
as excinfo:
138 hash(m.Comparable(15))
139 assert str(excinfo.value).startswith(
"unhashable type:")
141 for hashable
in (m.Hashable, m.Hashable2):
142 assert hashable(15)
is not hashable(15)
143 assert hashable(15) == hashable(15)
145 assert hash(hashable(15)) == 15
146 assert hash(hashable(15)) ==
hash(hashable(15))
150 with pytest.raises(TypeError)
as excinfo:
151 m.get_unhashable_HashMe_set()
152 assert str(excinfo.value.__cause__).startswith(
"unhashable type:")
def test_return_set_of_unhashable()
def test_overriding_eq_reset_hash()
static ConstructorStats & get(std::type_index type)
def test_operators_notimplemented()
def test_operator_overloading()