summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-08 01:57:40 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-08 01:57:40 +0000
commit7d414a1b52d193bab2c94cf56932e1eba23ba542 (patch)
tree69f6840e4f825ffc1047fe7cb0f52eba27b20d86 /tests
parent5f97aaeca4dc607a2d32e758c3ef6131ffb168a6 (diff)
downloadmicropython-7d414a1b52d193bab2c94cf56932e1eba23ba542.tar.gz
micropython-7d414a1b52d193bab2c94cf56932e1eba23ba542.zip
py: Parse big-int/float/imag constants directly in parser.
Previous to this patch, a big-int, float or imag constant was interned (made into a qstr) and then parsed at runtime to create an object each time it was needed. This is wasteful in RAM and not efficient. Now, these constants are parsed straight away in the parser and turned into objects. This allows constants with large numbers of digits (so addresses issue #1103) and takes us a step closer to #722.
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/int1.py3
-rw-r--r--tests/basics/int_mpz.py4
-rw-r--r--tests/float/cmath_fun.py2
-rw-r--r--tests/float/float1.py4
4 files changed, 12 insertions, 1 deletions
diff --git a/tests/basics/int1.py b/tests/basics/int1.py
index 89d4fd9d4b..fd9902f935 100644
--- a/tests/basics/int1.py
+++ b/tests/basics/int1.py
@@ -78,3 +78,6 @@ test('0b2', 2)
test('0o8', 8)
test('0xg', 16)
test('1 1', 16)
+
+# check that we don't parse this as a floating point number
+print(0x1e+1)
diff --git a/tests/basics/int_mpz.py b/tests/basics/int_mpz.py
index 0500d794cf..ee172edffe 100644
--- a/tests/basics/int_mpz.py
+++ b/tests/basics/int_mpz.py
@@ -55,3 +55,7 @@ for i in range(8):
print(-10000000000000000000000002 >> i)
print(-10000000000000000000000003 >> i)
print(-10000000000000000000000004 >> i)
+
+# test constant integer with more than 255 chars
+x = 0x84ce72aa8699df436059f052ac51b6398d2511e49631bcb7e71f89c499b9ee425dfbc13a5f6d408471b054f2655617cbbaf7937b7c80cd8865cf02c8487d30d2b0fbd8b2c4e102e16d828374bbc47b93852f212d5043c3ea720f086178ff798cc4f63f787b9c2e419efa033e7644ea7936f54462dc21a6c4580725f7f0e7d1aaaaaaa
+print(x)
diff --git a/tests/float/cmath_fun.py b/tests/float/cmath_fun.py
index e13271372e..dfb6c56bd2 100644
--- a/tests/float/cmath_fun.py
+++ b/tests/float/cmath_fun.py
@@ -12,7 +12,7 @@ print("%.5g" % e)
print("%.5g" % pi)
test_values_non_zero = []
-base_values = (0.0, 0.5, 1.23456, 10.)
+base_values = (0.0, 0.5, 1.2345, 10.)
for r in base_values:
for i in base_values:
if r != 0. or i != 0.:
diff --git a/tests/float/float1.py b/tests/float/float1.py
index bf1305c3d5..5971e6d0a7 100644
--- a/tests/float/float1.py
+++ b/tests/float/float1.py
@@ -14,3 +14,7 @@ try:
1.0 // 0
except ZeroDivisionError:
print("ZeroDivisionError")
+
+# test constant float with more than 255 chars
+x = 1.84728699436059052516398251149631771898472869943605905251639825114963177189847286994360590525163982511496317718984728699436059052516398251149631771898472869943605905251639825114963177189847286994360590525163982511496317718984728699436059052516398251149631771898472869943605905251639825114963177189
+print("%.5f" % x)