diff --git a/tests/extmod/ujson_dumps.py b/tests/extmod/ujson_dumps.py index 16a695ab5c..c0ee60d736 100644 --- a/tests/extmod/ujson_dumps.py +++ b/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([])) diff --git a/tests/extmod/ujson_dumps_float.py b/tests/extmod/ujson_dumps_float.py new file mode 100644 index 0000000000..f6ba5f1139 --- /dev/null +++ b/tests/extmod/ujson_dumps_float.py @@ -0,0 +1,6 @@ +try: + import ujson as json +except ImportError: + import json + +print(json.dumps(1.2)) diff --git a/tests/extmod/ujson_loads.py b/tests/extmod/ujson_loads.py index 75e61dacd9..22f4a02c41 100644 --- a/tests/extmod/ujson_loads.py +++ b/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]')) diff --git a/tests/extmod/ujson_loads_float.py b/tests/extmod/ujson_loads_float.py new file mode 100644 index 0000000000..f5e754608c --- /dev/null +++ b/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')) diff --git a/tests/run-tests b/tests/run-tests index c4868b3c2b..bd2cbfd029 100755 --- a/tests/run-tests +++ b/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':