2018-07-22 10:19:22 -04:00
|
|
|
try:
|
|
|
|
import urandom as random
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
import random
|
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
try:
|
|
|
|
random.randint
|
|
|
|
except AttributeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("SKIP")
|
2018-07-22 10:19:22 -04:00
|
|
|
raise SystemExit
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
print("random")
|
2018-07-22 10:19:22 -04:00
|
|
|
for i in range(50):
|
|
|
|
assert 0 <= random.random() < 1
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
print("uniform")
|
2018-07-22 10:19:22 -04:00
|
|
|
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
|