summaryrefslogtreecommitdiff
path: root/simplejson/tests
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2013-05-01 13:00:06 -0700
committerBob Ippolito <bob@redivi.com>2013-05-01 13:00:06 -0700
commit236c8a174c0e333608e992f6f7ec7826c2fd1cd8 (patch)
tree3a75f4ab4e8a7d6a1af1dd793a0cea99bf0a6fe0 /simplejson/tests
parent928421f68ff2128c5397553a57f3d76a75e39ca4 (diff)
downloadsimplejson-236c8a174c0e333608e992f6f7ec7826c2fd1cd8.tar.gz
ignore_nan #63ecma-262-63
Diffstat (limited to 'simplejson/tests')
-rw-r--r--simplejson/tests/test_float.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/simplejson/tests/test_float.py b/simplejson/tests/test_float.py
index f61ed68..e382ec2 100644
--- a/simplejson/tests/test_float.py
+++ b/simplejson/tests/test_float.py
@@ -5,13 +5,21 @@ import simplejson as json
from simplejson.decoder import NaN, PosInf, NegInf
class TestFloat(TestCase):
- def test_degenerates(self):
+ def test_degenerates_allow(self):
for inf in (PosInf, NegInf):
self.assertEqual(json.loads(json.dumps(inf)), inf)
# Python 2.5 doesn't have math.isnan
nan = json.loads(json.dumps(NaN))
self.assertTrue((0 + nan) != nan)
+ def test_degenerates_ignore(self):
+ for f in (PosInf, NegInf, NaN):
+ self.assertEqual(json.loads(json.dumps(f, ignore_nan=True)), None)
+
+ def test_degenerates_deny(self):
+ for f in (PosInf, NegInf, NaN):
+ self.assertRaises(ValueError, json.dumps, f, allow_nan=False)
+
def test_floats(self):
for num in [1617161771.7650001, math.pi, math.pi**100,
math.pi**-100, 3.1]: