import assert from "node:assert/strict"; import fs from "node:fs"; import * as runner from "../runner.mjs"; import { makeRandom, } from "../rand.mjs"; const test_makeRandom = async t => { t.start("makeRandom()"); await t.test("known expected values", () => { const expected1 = [ 545331265, 2211535594, 4152021490, 3857419313, 1118735928, 3031474347, 3853601519, 3345048107, 1618127707, 4001288224, 1444061399, 2700534436, 1938647176, 1459718602, 3608868106, 926825740, 528719691, 508226068, 2332279787, 357437743, 1602075314, 1655472598, 1924131686, 4125580919, 555943458, 4047836046, 3693150918, 1515015978, 3523541186, 753964207, 1512058436, 682070622, 983063469, 4097791860, 3336260823, 603291380, 2554576084, 139062484, 590788013, 3608810491, 3663176645, 3481732081, 1011496919, 2935401636, 628041163, 3997974947, 2533467101, 2287863463, 2465361808, 1196937660, 263152482, 618228754, 2535860367, 3089904367, 1053769440, 1270818139, 1462199892, 49766906, 4229377745, 445624458, 3949395950, 4102223196, 162228180, 352248782, 3700326028, 965464548, 3236553557, 1342363444, 1740229486, 4006226087, 1475432391, 2100043423, 734083679, 2197742340, 1695047538, 2684537025, 2755935210, 2185177924, 1179365521, 682202996, 1985796754, 1203188028, 3742512741, 2573038834, 1722845493, 971634808, 2622456659, 1542773708, 506664990, 516191900, 3015858858, 2439287065, 1778261054, 3352336947, 1470361474, 2832338531, 2559479753, 2841821596, 858410480, 1311022275, ]; const expected2 = [ 1867215825, 1512725508, 59490082, 898255083, 2128587452, 3375572255, 3011978101, 664390052, 712189293, 1309145867, 1574443536, 3005563625, 1937221174, 2592810353, 1221596501, 3864084723, 2447880554, 1373397507, 4101388729, 1434258649, 2876658371, 694177935, 1850641240, 2934786942, 3613830458, 3660625740, 1450431957, 978896710, 108365537, 1669305275, 1505684879, 1989942961, 4089952722, 2832268551, 27863256, 3866494241, 3916427650, 3309597508, 24597008, 3442418170, 1617059167, 175885832, 854293503, 3965431971, 3276364445, 4079612430, 1622146979, 1665096344, 2283667308, 2042586700, 2997013224, 1214521941, 860865914, 3204144669, 3352312876, 407025370, 1854088521, 1518454983, 2467488963, 3014922727, 667505194, 1382726996, 3519130642, 3473985175, 387425140, 826920070, 3222196824, 3272392876, 2814202151, 1958017767, 2343175108, 513394477, 983853656, 3389045986, 177790781, 1853562919, 1417029053, 115479138, 3505632337, 339954849, 2552460743, 1260703764, 1719642924, 3129628830, 1828716278, 3537151540, 4169628597, 444526909, 4191927207, 3891278677, 1954375449, 3973495864, 2231816005, 4062939046, 2084239497, 3470238230, 1145760705, 2114090486, 4245867725, 1687967890, ]; const expected3 = JSON.parse( fs.readFileSync("tests/bigger-rand-output.txt"), ); const given1 = Array.from( new Array(expected1.length), makeRandom(123456), ); const given2 = Array.from( new Array(expected2.length), makeRandom(123457), ); const given3 = Array.from( new Array(expected3.length), makeRandom(2222), ); assert.deepEqual(given1, expected1); assert.deepEqual(given2, expected2); assert.deepEqual(given3, expected3); }); }; await runner.runTests([ test_makeRandom, ]);