Skip to content
Prev Previous commit
Next Next commit
+ test invariant
  • Loading branch information
skirpichev committed Jul 3, 2024
commit 1cec4abd4c93b700b2f71d3bf3d433d8bd99ca22
5 changes: 5 additions & 0 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,11 @@ def __getitem__(self, index):
sum(([x] for x in range(10)), empty)
self.assertEqual(empty, [])

xs = [complex(random.random() - .5, random.random() - .5)
for _ in range(10000)]
self.assertEqual(sum(xs), complex(sum(_.real for _ in xs),
Comment thread
rhettinger marked this conversation as resolved.
Outdated
sum(_.imag for _ in xs)))
Comment thread
rhettinger marked this conversation as resolved.
Outdated

@requires_IEEE_754
@unittest.skipIf(HAVE_DOUBLE_ROUNDING,
"sum accuracy not guaranteed on machines with double rounding")
Expand Down