circuitpython/tests/extmod/urandom_extra_float.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
482 B
Python
Raw Normal View History

try:
import urandom as random
except ImportError:
try:
import random
except ImportError:
print("SKIP")
raise SystemExit
try:
random.randint
except AttributeError:
2021-04-20 01:22:44 -04:00
print("SKIP")
raise SystemExit
2021-04-20 01:22:44 -04:00
print("random")
for i in range(50):
assert 0 <= random.random() < 1
2021-04-20 01:22:44 -04:00
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