Explicitly test JS truthiness of NaN
Marco Ricci

Marco Ricci commited on 2025-01-25 00:13:39
Zeige 1 geänderte Dateien mit 3 Einfügungen und 0 Löschungen.

... ...
@@ -5,6 +5,7 @@
5 5
 from __future__ import annotations
6 6
 
7 7
 import copy
8
+import math
8 9
 
9 10
 import hypothesis
10 11
 import pytest
... ...
@@ -57,6 +58,7 @@ from derivepassphrase import _types
57 58
         strategies.builds(frozenset),
58 59
     ),
59 60
 )
61
+@hypothesis.example(float('nan'))
60 62
 def test_100_js_truthiness(value: Any) -> None:
61 63
     """Determine the truthiness of a value according to JavaScript.
62 64
 
... ...
@@ -69,6 +71,7 @@ def test_100_js_truthiness(value: Any) -> None:
69 71
         and value != 0
70 72
         and value != 0.0
71 73
         and value != ''
74
+        and not (isinstance(value, float) and math.isnan(value))
72 75
     )
73 76
     assert _types.js_truthiness(value) == expected
74 77
 
75 78