Skip to content

Commit

Permalink
+ sync with pr
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Nov 26, 2024
1 parent 8ebbf17 commit 479f806
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from test.support.import_helper import import_module
from test.support.os_helper import (EnvironmentVarGuard, TESTFN, unlink)
from test.support.script_helper import assert_python_ok
from test.support.testcase import ComplexesAreIdenticalMixin
from test.support.warnings_helper import check_warnings
from test.support import requires_IEEE_754
from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -151,7 +152,7 @@ def map_char(arg):
def pack(*args):
return args

class BuiltinTest(unittest.TestCase):
class BuiltinTest(ComplexesAreIdenticalMixin, unittest.TestCase):
# Helper to check picklability
def check_iter_pickle(self, it, seq, proto):
itorg = it
Expand Down Expand Up @@ -1902,6 +1903,13 @@ def __getitem__(self, index):
self.assertEqual(sum(xs), complex(sum(z.real for z in xs),
sum(z.imag for z in xs)))

# test that sum() of complex and real numbers doesn't
# smash sign of imaginary 0
self.assertComplexesAreIdentical(sum([complex(1, -0.0), 1]),
complex(2, -0.0))
self.assertComplexesAreIdentical(sum([complex(1, -0.0), 1.0]),
complex(2, -0.0))

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

0 comments on commit 479f806

Please sign in to comment.