aboutsummaryrefslogtreecommitdiff
path: root/tests/float
diff options
context:
space:
mode:
authorDamien George2015-03-25 23:10:09 +0000
committerDamien George2015-03-25 23:10:09 +0000
commit214179b430ebc1101e28b19248b6166f5e511e6b (patch)
tree74f8dc7b2e9dbfd902514b82a698e9ddaa8bb4bc /tests/float
parent44f65c0e2f5ce27ce90bbec218ecb39cba9d75a2 (diff)
tests: Add tests for SyntaxError, TypeError, and other missing things.
This is intended to improve coverage of the test suite.
Diffstat (limited to 'tests/float')
-rw-r--r--tests/float/complex1.py11
-rw-r--r--tests/float/float1.py6
-rw-r--r--tests/float/int_big_float.py3
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/float/complex1.py b/tests/float/complex1.py
index 6cfbff61b..eafa53746 100644
--- a/tests/float/complex1.py
+++ b/tests/float/complex1.py
@@ -16,6 +16,8 @@ print(+(1j))
print(-(1 + 2j))
# binary ops
+print(1j + False)
+print(1j + True)
print(1j + 2)
print(1j + 2j)
print(1j - 2)
@@ -30,3 +32,12 @@ ans = 1j ** 2.5j; print("%.5g %.5g" % (ans.real, ans.imag))
# builtin abs
print(abs(1j))
print("%.5g" % abs(1j + 2))
+
+# convert bignum to complex on rhs
+ans = 1j + (1 << 70); print("%.5g %.5g" % (ans.real, ans.imag))
+
+# can't convert rhs to complex
+try:
+ 1j + []
+except TypeError:
+ print("TypeError")
diff --git a/tests/float/float1.py b/tests/float/float1.py
index 7b5887ff0..9e4bb85cd 100644
--- a/tests/float/float1.py
+++ b/tests/float/float1.py
@@ -20,6 +20,12 @@ try:
except ZeroDivisionError:
print("ZeroDivisionError")
+# can't convert list to float
+try:
+ float([])
+except TypeError:
+ print("TypeError")
+
# test constant float with more than 255 chars
x = 1.84728699436059052516398251149631771898472869943605905251639825114963177189847286994360590525163982511496317718984728699436059052516398251149631771898472869943605905251639825114963177189847286994360590525163982511496317718984728699436059052516398251149631771898472869943605905251639825114963177189
print("%.5f" % x)
diff --git a/tests/float/int_big_float.py b/tests/float/int_big_float.py
index a5fb2700f..5b8aaa878 100644
--- a/tests/float/int_big_float.py
+++ b/tests/float/int_big_float.py
@@ -2,6 +2,9 @@
i = 1 << 65
+# convert bignum to float on rhs
+print("%.5g" % (2.0 * i))
+
# this should convert to float
print("%.5g" % (i / 5))