summaryrefslogtreecommitdiffstatshomepage
path: root/tests/float/float2int_doubleprec_intbig.py
diff options
context:
space:
mode:
authorDavid Lechner <david@lechnology.com>2020-03-22 21:26:08 -0500
committerDamien George <damien.p.george@gmail.com>2020-03-30 13:21:58 +1100
commit3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch)
tree94ff44f8eabba0039582c245b901173597edd11e /tests/float/float2int_doubleprec_intbig.py
parent488613bca6c460340ed2995ae5cafafe22d0bfff (diff)
downloadmicropython-3dc324d3f1312e40d3a8ed87e7244966bb756f26.tar.gz
micropython-3dc324d3f1312e40d3a8ed87e7244966bb756f26.zip
tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
Diffstat (limited to 'tests/float/float2int_doubleprec_intbig.py')
-rw-r--r--tests/float/float2int_doubleprec_intbig.py81
1 files changed, 42 insertions, 39 deletions
diff --git a/tests/float/float2int_doubleprec_intbig.py b/tests/float/float2int_doubleprec_intbig.py
index de2137d66c..24d30fe691 100644
--- a/tests/float/float2int_doubleprec_intbig.py
+++ b/tests/float/float2int_doubleprec_intbig.py
@@ -6,6 +6,7 @@ except:
import struct
import sys
+
maxsize_bits = 0
maxsize = sys.maxsize
while maxsize:
@@ -31,32 +32,33 @@ if ll_type is None:
# This case occurs with time.time() values
if ll_type != 0:
- print(int(1418774543.))
- print("%d" % 1418774543.)
+ print(int(1418774543.0))
+ print("%d" % 1418774543.0)
if ll_type == 3:
- print(int(2.**100))
- print("%d" % 2.**100)
+ print(int(2.0 ** 100))
+ print("%d" % 2.0 ** 100)
else:
- print(int(1073741823.))
- print("%d" % 1073741823.)
+ print(int(1073741823.0))
+ print("%d" % 1073741823.0)
testpass = True
-p2_rng = ((30,63,1024),(62,63,1024))[is_64bit][ll_type]
-for i in range(0,p2_rng):
- bitcnt = len(bin(int(2.**i))) - 3;
+p2_rng = ((30, 63, 1024), (62, 63, 1024))[is_64bit][ll_type]
+for i in range(0, p2_rng):
+ bitcnt = len(bin(int(2.0 ** i))) - 3
if i != bitcnt:
- print('fail: 2**%u was %u bits long' % (i, bitcnt));
+ print("fail: 2**%u was %u bits long" % (i, bitcnt))
testpass = False
-print("power of 2 test: %s" % (testpass and 'passed' or 'failed'))
+print("power of 2 test: %s" % (testpass and "passed" or "failed"))
testpass = True
-p10_rng = ((9,18,23),(18,18,23))[is_64bit][ll_type]
-for i in range(0,p10_rng):
- digcnt = len(str(int(10.**i))) - 1;
+p10_rng = ((9, 18, 23), (18, 18, 23))[is_64bit][ll_type]
+for i in range(0, p10_rng):
+ digcnt = len(str(int(10.0 ** i))) - 1
if i != digcnt:
- print('fail: 10**%u was %u digits long' % (i, digcnt));
+ print("fail: 10**%u was %u digits long" % (i, digcnt))
testpass = False
-print("power of 10 test: %s" % (testpass and 'passed' or 'failed'))
+print("power of 10 test: %s" % (testpass and "passed" or "failed"))
+
def fp2int_test(num, name, should_fail):
try:
@@ -64,37 +66,38 @@ def fp2int_test(num, name, should_fail):
passed = ~should_fail
except:
passed = should_fail
- print('%s: %s' % (name, passed and 'passed' or 'failed'))
+ print("%s: %s" % (name, passed and "passed" or "failed"))
+
if ll_type != 2:
if ll_type == 0:
if is_64bit:
- neg_bad_fp = -1.00000005*2.**62.
- pos_bad_fp = 2.**62.
- neg_good_fp = -2.**62.
- pos_good_fp = 0.99999993*2.**62.
+ neg_bad_fp = -1.00000005 * 2.0 ** 62.0
+ pos_bad_fp = 2.0 ** 62.0
+ neg_good_fp = -(2.0 ** 62.0)
+ pos_good_fp = 0.99999993 * 2.0 ** 62.0
else:
- neg_bad_fp = -1.00000005*2.**30.
- pos_bad_fp = 2.**30.
- neg_good_fp = -2.**30.
- pos_good_fp = 0.9999999499*2.**30.
+ neg_bad_fp = -1.00000005 * 2.0 ** 30.0
+ pos_bad_fp = 2.0 ** 30.0
+ neg_good_fp = -(2.0 ** 30.0)
+ pos_good_fp = 0.9999999499 * 2.0 ** 30.0
else:
- neg_bad_fp = -0.51*2.**64.
- pos_bad_fp = 2.**63.
- neg_good_fp = -2.**63.
- pos_good_fp = 1.9999998*2.**62.
+ neg_bad_fp = -0.51 * 2.0 ** 64.0
+ pos_bad_fp = 2.0 ** 63.0
+ neg_good_fp = -(2.0 ** 63.0)
+ pos_good_fp = 1.9999998 * 2.0 ** 62.0
- fp2int_test(neg_bad_fp, 'neg bad', True)
- fp2int_test(pos_bad_fp, 'pos bad', True)
- fp2int_test(neg_good_fp, 'neg good', False)
- fp2int_test(pos_good_fp, 'pos good', False)
+ fp2int_test(neg_bad_fp, "neg bad", True)
+ fp2int_test(pos_bad_fp, "pos bad", True)
+ fp2int_test(neg_good_fp, "neg good", False)
+ fp2int_test(pos_good_fp, "pos good", False)
else:
- fp2int_test(-1.9999999999999981*2.**1023., 'large neg', False)
- fp2int_test(1.9999999999999981*2.**1023., 'large pos', False)
+ fp2int_test(-1.9999999999999981 * 2.0 ** 1023.0, "large neg", False)
+ fp2int_test(1.9999999999999981 * 2.0 ** 1023.0, "large pos", False)
-fp2int_test(float('inf'), 'inf test', True)
-fp2int_test(float('nan'), 'NaN test', True)
+fp2int_test(float("inf"), "inf test", True)
+fp2int_test(float("nan"), "NaN test", True)
# test numbers < 1 (this used to fail; see issue #1044)
-fp2int_test(0.0001, 'small num', False)
-struct.pack('I', int(1/2))
+fp2int_test(0.0001, "small num", False)
+struct.pack("I", int(1 / 2))