tests: Make tests work on targets without float support.
This commit is contained in:
parent
7be5bb3672
commit
6572029dc0
@ -37,7 +37,7 @@ print(2 + 2 * 2)
|
|||||||
# BAD: (-2)**2 = 4
|
# BAD: (-2)**2 = 4
|
||||||
print(-2**2)
|
print(-2**2)
|
||||||
# OK: 2**(-1) = 0.5
|
# OK: 2**(-1) = 0.5
|
||||||
print(2**-1)
|
print(2**-0)
|
||||||
|
|
||||||
# (expr...)
|
# (expr...)
|
||||||
print((2 + 2) * 2)
|
print((2 + 2) * 2)
|
||||||
|
@ -67,13 +67,3 @@ try:
|
|||||||
random.choice([])
|
random.choice([])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print('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
|
|
||||||
|
24
tests/extmod/urandom_extra_float.py
Normal file
24
tests/extmod/urandom_extra_float.py
Normal file
@ -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
|
@ -31,7 +31,7 @@ def print_exc(e):
|
|||||||
|
|
||||||
# basic exception message
|
# basic exception message
|
||||||
try:
|
try:
|
||||||
1/0
|
raise Exception('msg')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('caught')
|
print('caught')
|
||||||
print_exc(e)
|
print_exc(e)
|
||||||
@ -40,7 +40,7 @@ except Exception as e:
|
|||||||
def f():
|
def f():
|
||||||
g()
|
g()
|
||||||
def g():
|
def g():
|
||||||
2/0
|
raise Exception('fail')
|
||||||
try:
|
try:
|
||||||
f()
|
f()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -277,8 +277,12 @@ def run_tests(pyb, tests, args, base_path="."):
|
|||||||
skip_tests.add('thread/stress_recurse.py') # has reliability issues
|
skip_tests.add('thread/stress_recurse.py') # has reliability issues
|
||||||
|
|
||||||
if upy_float_precision == 0:
|
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_dumps_float.py')
|
||||||
skip_tests.add('extmod/ujson_loads_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')
|
skip_tests.add('misc/rge_sm.py')
|
||||||
if upy_float_precision < 32:
|
if upy_float_precision < 32:
|
||||||
skip_tests.add('float/float2int_intbig.py') # requires fp32, there's float2int_fp30_intbig.py instead
|
skip_tests.add('float/float2int_intbig.py') # requires fp32, there's float2int_fp30_intbig.py instead
|
||||||
|
Loading…
Reference in New Issue
Block a user