Skip to content

Commit

Permalink
* dist: L2575, L2577
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Sep 28, 2023
1 parent ead9eee commit 3a80c78
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,10 @@ def testDist(self):
# Test allowable types (those with __float__)
self.assertEqual(dist((14.0, 1.0), (2.0, -4.0)), 13.0)
self.assertEqual(dist((14, 1), (2, -4)), 13)
self.assertEqual(dist((FloatLike(14.), 1), (2, -4)), 13)
self.assertEqual(dist((11, 1), (FloatLike(-1.), -4)), 13)
self.assertEqual(dist((14, FloatLike(-1.)), (2, -6)), 13)
self.assertEqual(dist((14, -1), (2, -6)), 13)
self.assertEqual(dist((D(14), D(1)), (D(2), D(-4))), D(13))
self.assertEqual(dist((F(14, 32), F(1, 32)), (F(2, 32), F(-4, 32))),
F(13, 32))
Expand Down Expand Up @@ -1016,6 +1020,12 @@ class T(tuple):
with self.assertRaises(TypeError):
dist([1], 2)

class BadFloat:
__float__ = BadDescr()

with self.assertRaises(ValueError):
dist([1], [BadFloat()])

# Verify that the one dimensional case is equivalent to abs()
for i in range(20):
p, q = random.random(), random.random()
Expand Down

0 comments on commit 3a80c78

Please sign in to comment.