summaryrefslogtreecommitdiff
path: root/tests/float/float1.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-09-04 14:16:27 +1000
committerDamien George <damien.p.george@gmail.com>2017-09-04 14:16:27 +1000
commitd4b75f6b6822885e331c69a74e56e23af40a6264 (patch)
treeab0d1c7d77cb366abc9379b00b22cee07aa9a9c1 /tests/float/float1.py
parent9950865c39044e9fef295d0676af7c5fd55289ea (diff)
py/obj: Fix comparison of float/complex NaN with itself.
IEEE floating point is specified such that a comparison of NaN with itself returns false, and Python respects these semantics. This patch makes uPy also have these semantics. The fix has a minor impact on the speed of the object-equality fast-path, but that seems to be unavoidable and it's much more important to have correct behaviour (especially in this case where the wrong answer for nan==nan is silently returned).
Diffstat (limited to 'tests/float/float1.py')
-rw-r--r--tests/float/float1.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/float/float1.py b/tests/float/float1.py
index 93f6f014c..137dacc23 100644
--- a/tests/float/float1.py
+++ b/tests/float/float1.py
@@ -60,6 +60,11 @@ print(1.2 <= -3.4)
print(1.2 >= 3.4)
print(1.2 >= -3.4)
+# comparison of nan is special
+nan = float('nan')
+print(nan == 1.2)
+print(nan == nan)
+
try:
1.0 / 0
except ZeroDivisionError: