summaryrefslogtreecommitdiff
path: root/tests/float
diff options
context:
space:
mode:
Diffstat (limited to 'tests/float')
-rw-r--r--tests/float/builtin_float_round.py4
-rw-r--r--tests/float/complex1.py6
-rw-r--r--tests/float/float1.py6
-rw-r--r--tests/float/string_format_modulo.py2
-rw-r--r--tests/float/string_format_modulo3.py4
-rw-r--r--tests/float/string_format_modulo3.py.exp3
6 files changed, 23 insertions, 2 deletions
diff --git a/tests/float/builtin_float_round.py b/tests/float/builtin_float_round.py
index 4419b744b..de72514db 100644
--- a/tests/float/builtin_float_round.py
+++ b/tests/float/builtin_float_round.py
@@ -13,5 +13,5 @@ for i in range(11):
print(round((i - 5) / 2))
# test second arg
-# TODO uPy currently only supports second arg being 0
-print(round(1.4, 0))
+for i in range(-1, 3):
+ print(round(1.47, i))
diff --git a/tests/float/complex1.py b/tests/float/complex1.py
index ebe4b0f37..027d12583 100644
--- a/tests/float/complex1.py
+++ b/tests/float/complex1.py
@@ -75,6 +75,12 @@ try:
except TypeError:
print("TypeError")
+#small int on LHS, complex on RHS, unsupported op
+try:
+ print(1 | 1j)
+except TypeError:
+ print('TypeError')
+
# zero division
try:
1j / 0
diff --git a/tests/float/float1.py b/tests/float/float1.py
index f21f5bcdd..0e115032b 100644
--- a/tests/float/float1.py
+++ b/tests/float/float1.py
@@ -87,6 +87,12 @@ try:
except TypeError:
print("TypeError")
+# small int on LHS, float on RHS, unsupported op
+try:
+ print(1 | 1.0)
+except TypeError:
+ print('TypeError')
+
# can't convert list to float
try:
float([])
diff --git a/tests/float/string_format_modulo.py b/tests/float/string_format_modulo.py
index 681e9eb80..03c8dd00a 100644
--- a/tests/float/string_format_modulo.py
+++ b/tests/float/string_format_modulo.py
@@ -42,3 +42,5 @@ print(('%.40g' % 1e-1)[:2])
print(('%.40g' % 1e-2)[:2])
print(('%.40g' % 1e-3)[:2])
print(('%.40g' % 1e-4)[:2])
+
+print("%.0g" % 1) # 0 precision 'g'
diff --git a/tests/float/string_format_modulo3.py b/tests/float/string_format_modulo3.py
new file mode 100644
index 000000000..563964786
--- /dev/null
+++ b/tests/float/string_format_modulo3.py
@@ -0,0 +1,4 @@
+# uPy and CPython outputs differ for the following
+print("%.1g" % -9.9) # round up 'g' with '-' sign
+print("%.1e" % 9.99) # round up with positive exponent
+print("%.1e" % 0.999) # round up with negative exponent
diff --git a/tests/float/string_format_modulo3.py.exp b/tests/float/string_format_modulo3.py.exp
new file mode 100644
index 000000000..b158c7d7f
--- /dev/null
+++ b/tests/float/string_format_modulo3.py.exp
@@ -0,0 +1,3 @@
+-10
+1.00e+01
+1.00e-00