1--TEST--
2Random: Randomizer: getFloat(): Basic functionality
3--FILE--
4<?php
5
6use Random\Engine;
7use Random\Engine\Mt19937;
8use Random\Engine\PcgOneseq128XslRr64;
9use Random\Engine\Secure;
10use Random\Engine\Test\TestShaEngine;
11use Random\Engine\Xoshiro256StarStar;
12use Random\IntervalBoundary;
13use Random\Randomizer;
14
15require __DIR__ . "/../../engines.inc";
16
17$engines = [];
18$engines[] = new Mt19937(null, MT_RAND_MT19937);
19$engines[] = new Mt19937(null, MT_RAND_PHP);
20$engines[] = new PcgOneseq128XslRr64();
21$engines[] = new Xoshiro256StarStar();
22$engines[] = new Secure();
23$engines[] = new TestShaEngine();
24$max = getenv("SKIP_SLOW_TESTS") ? 3_000.0 : 10_000.0;
25
26foreach ($engines as $engine) {
27    echo $engine::class, PHP_EOL;
28
29    $randomizer = new Randomizer($engine);
30
31    // Basic range test.
32    for ($i = 0.0; $i < $max; $i += 1.2345) {
33        $result = $randomizer->getFloat(-$i, $i, IntervalBoundary::ClosedClosed);
34
35        if ($result > $i || $result < -$i) {
36            die("failure: out of range at {$i}");
37        }
38    }
39}
40
41die('success');
42
43?>
44--EXPECTF--
45Deprecated: Constant MT_RAND_PHP is deprecated in %s on line %d
46
47Deprecated: The MT_RAND_PHP variant of Mt19937 is deprecated in %s on line %d
48Random\Engine\Mt19937
49Random\Engine\Mt19937
50Random\Engine\PcgOneseq128XslRr64
51Random\Engine\Xoshiro256StarStar
52Random\Engine\Secure
53Random\Engine\Test\TestShaEngine
54success
55