Browse Source

tests: Split out json float tests to separate files.

pull/1279/merge
Damien George 10 years ago
parent
commit
e44c1d3ace
  1. 1
      tests/extmod/ujson_dumps.py
  2. 6
      tests/extmod/ujson_dumps_float.py
  3. 7
      tests/extmod/ujson_loads.py
  4. 13
      tests/extmod/ujson_loads_float.py
  5. 4
      tests/run-tests

1
tests/extmod/ujson_dumps.py

@ -7,7 +7,6 @@ print(json.dumps(False))
print(json.dumps(True))
print(json.dumps(None))
print(json.dumps(1))
print(json.dumps(1.2))
print(json.dumps('abc'))
print(json.dumps('\x00\x01\x7e'))
print(json.dumps([]))

6
tests/extmod/ujson_dumps_float.py

@ -0,0 +1,6 @@
try:
import ujson as json
except ImportError:
import json
print(json.dumps(1.2))

7
tests/extmod/ujson_loads.py

@ -6,8 +6,6 @@ except:
def my_print(o):
if isinstance(o, dict):
print('sorted dict', sorted(o.items()))
elif isinstance(o, float):
print('%.3f' % o)
else:
print(o)
@ -15,12 +13,7 @@ my_print(json.loads('null'))
my_print(json.loads('false'))
my_print(json.loads('true'))
my_print(json.loads('1'))
my_print(json.loads('1.2'))
my_print(json.loads('1e2'))
my_print(json.loads('-2'))
my_print(json.loads('-2.3'))
my_print(json.loads('-2e3'))
my_print(json.loads('-2e-3'))
my_print(json.loads('"abc\\u0064e"'))
my_print(json.loads('[]'))
my_print(json.loads('[null]'))

13
tests/extmod/ujson_loads_float.py

@ -0,0 +1,13 @@
try:
import ujson as json
except:
import json
def my_print(o):
print('%.3f' % o)
my_print(json.loads('1.2'))
my_print(json.loads('1e2'))
my_print(json.loads('-2.3'))
my_print(json.loads('-2e3'))
my_print(json.loads('-2e-3'))

4
tests/run-tests

@ -155,8 +155,8 @@ def run_tests(pyb, tests, args):
skip_tests.add('misc/rge_sm.py') # requires floating point
skip_tests.update({'extmod/uctypes_%s.py' % t for t in 'bytearray le native_le ptr_le ptr_native_le sizeof sizeof_native'.split()}) # requires uctypes
skip_tests.add('extmod/zlibd_decompress.py') # requires zlib
skip_tests.add('extmod/ujson_dumps.py') # requires floating point
skip_tests.add('extmod/ujson_loads.py') # requires floating point
skip_tests.add('extmod/ujson_dumps_float.py') # requires floating point
skip_tests.add('extmod/ujson_loads_float.py') # requires floating point
# Some tests are known to fail on 64-bit machines
if pyb is None and platform.architecture()[0] == '64bit':

Loading…
Cancel
Save