summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyke van Laethem <aykevanlaethem@gmail.com>2018-07-22 16:19:22 +0200
committerDamien George <damien.p.george@gmail.com>2018-08-04 15:14:23 +1000
commit6572029dc0665e58c2ea7355c9e541bdf83105a4 (patch)
tree7590e55e282f43050f0a1717c41fdc6667663f98
parent7be5bb367212b6949e74f73d90af01f8b68f1352 (diff)
tests: Make tests work on targets without float support.
-rw-r--r--tests/basics/op_precedence.py2
-rw-r--r--tests/extmod/urandom_extra.py10
-rw-r--r--tests/extmod/urandom_extra_float.py24
-rw-r--r--tests/misc/print_exception.py4
-rwxr-xr-xtests/run-tests4
5 files changed, 31 insertions, 13 deletions
diff --git a/tests/basics/op_precedence.py b/tests/basics/op_precedence.py
index 519a2a113..7d8302ba4 100644
--- a/tests/basics/op_precedence.py
+++ b/tests/basics/op_precedence.py
@@ -37,7 +37,7 @@ print(2 + 2 * 2)
# BAD: (-2)**2 = 4
print(-2**2)
# OK: 2**(-1) = 0.5
-print(2**-1)
+print(2**-0)
# (expr...)
print((2 + 2) * 2)
diff --git a/tests/extmod/urandom_extra.py b/tests/extmod/urandom_extra.py
index f5a34e168..0cfd9280b 100644
--- a/tests/extmod/urandom_extra.py
+++ b/tests/extmod/urandom_extra.py
@@ -67,13 +67,3 @@ try:
random.choice([])
except IndexError:
print('IndexError')
-
-print('random')
-for i in range(50):
- assert 0 <= random.random() < 1
-
-print('uniform')
-for i in range(50):
- assert 0 <= random.uniform(0, 4) <= 4
- assert 2 <= random.uniform(2, 6) <= 6
- assert -2 <= random.uniform(-2, 2) <= 2
diff --git a/tests/extmod/urandom_extra_float.py b/tests/extmod/urandom_extra_float.py
new file mode 100644
index 000000000..f665fd18a
--- /dev/null
+++ b/tests/extmod/urandom_extra_float.py
@@ -0,0 +1,24 @@
+try:
+ import urandom as random
+except ImportError:
+ try:
+ import random
+ except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+try:
+ random.randint
+except AttributeError:
+ print('SKIP')
+ raise SystemExit
+
+print('random')
+for i in range(50):
+ assert 0 <= random.random() < 1
+
+print('uniform')
+for i in range(50):
+ assert 0 <= random.uniform(0, 4) <= 4
+ assert 2 <= random.uniform(2, 6) <= 6
+ assert -2 <= random.uniform(-2, 2) <= 2
diff --git a/tests/misc/print_exception.py b/tests/misc/print_exception.py
index f120fe1e1..f33162404 100644
--- a/tests/misc/print_exception.py
+++ b/tests/misc/print_exception.py
@@ -31,7 +31,7 @@ def print_exc(e):
# basic exception message
try:
- 1/0
+ raise Exception('msg')
except Exception as e:
print('caught')
print_exc(e)
@@ -40,7 +40,7 @@ except Exception as e:
def f():
g()
def g():
- 2/0
+ raise Exception('fail')
try:
f()
except Exception as e:
diff --git a/tests/run-tests b/tests/run-tests
index dd88ac0af..0a70963d7 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -277,8 +277,12 @@ def run_tests(pyb, tests, args, base_path="."):
skip_tests.add('thread/stress_recurse.py') # has reliability issues
if upy_float_precision == 0:
+ skip_tests.add('extmod/uctypes_le_float.py')
+ skip_tests.add('extmod/uctypes_native_float.py')
+ skip_tests.add('extmod/uctypes_sizeof_float.py')
skip_tests.add('extmod/ujson_dumps_float.py')
skip_tests.add('extmod/ujson_loads_float.py')
+ skip_tests.add('extmod/urandom_extra_float.py')
skip_tests.add('misc/rge_sm.py')
if upy_float_precision < 32:
skip_tests.add('float/float2int_intbig.py') # requires fp32, there's float2int_fp30_intbig.py instead