neyuki 0.6.2

A small Lua-like scripting language implemented in Rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
local math = require("@neyuki/math")

for i in {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} do
    local value = math.random(1, 10)
    assert(value >= 1 and value <= 10, "random value is outside the requested range")
end

local largeMin = 0x1_0000_0000_0000_0000
local largeMax = largeMin + 10
local largeValue = math.random(largeMin, largeMax)
assert(typeof(largeValue) == "bigint", "bigint random should return a bigint")
assert(largeValue >= largeMin and largeValue <= largeMax, "bigint random value is outside the requested range")

local ok, err = try(math.random, 10, 1)
assert(not ok, "random should reject an inverted range")

print("[pass] randomization")