mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Regression: Invalid is_random implementation due to changes in 0.6.
This commit is contained in:
35
test/unit/stdlib/math/random.c3
Normal file
35
test/unit/stdlib/math/random.c3
Normal file
@@ -0,0 +1,35 @@
|
||||
module std::math::random @test;
|
||||
import std::math;
|
||||
|
||||
fn void test_regular_random()
|
||||
{
|
||||
for (int i = 0; i < 100; i++) assert(rand(45) < 45 && rand(45) >= 0);
|
||||
}
|
||||
|
||||
fn void test_next_bool()
|
||||
{
|
||||
DefaultRandom rand;
|
||||
random::seed_entropy(&rand);
|
||||
for (int i = 0; i < 100; i++) random::next_bool(&rand);
|
||||
}
|
||||
|
||||
fn void test_next()
|
||||
{
|
||||
DefaultRandom rand;
|
||||
random::seed_entropy(&rand);
|
||||
for (int i = 0; i < 100; i++) assert(random::next(&rand, 100) < 100.0 && random::next(&rand, 100) >= 0);
|
||||
}
|
||||
|
||||
fn void test_next_double()
|
||||
{
|
||||
DefaultRandom rand;
|
||||
random::seed_entropy(&rand);
|
||||
for (int i = 0; i < 100; i++) assert(random::next_double(&rand) < 1.0 && random::next_double(&rand) >= 0);
|
||||
}
|
||||
|
||||
fn void test_next_float()
|
||||
{
|
||||
DefaultRandom rand;
|
||||
random::seed_entropy(&rand);
|
||||
for (int i = 0; i < 100; i++) assert(random::next_float(&rand) < 1.0 && random::next_float(&rand) >= 0);
|
||||
}
|
||||
Reference in New Issue
Block a user