--!native
--!nonstrict
--!optimize 2
-- Compiled with roblox-ts v2.3.0
local TS = _G[script]
--/ <reference types="@rbxts/testez/globals" />
local LiveRandom = TS.import(script, script.Parent.Parent, "live-random").LiveRandom
return function()
	-- hopefully roblox doesn't prank me by changing the algorithm
	-- biome-ignore lint/correctness/noPrecisionLoss: shut up
	local SEED_TO_USE = 8949857.9991050064563751220703125
	describe("LiveRandom", function()
		describe("constructor", function()
			it("should return a LiveRandom", function()
				local liveRandom = LiveRandom.new(1, 10)
				expect((string.match(`{liveRandom}`, "^LiveRandom"))).to.be.ok()
				expect(TS.instanceof(liveRandom, LiveRandom)).to.equal(true)
			end)
		end)
		describe("LiveRandom.peek", function()
			it("should return the correct value every time", function()
				for _ = 1, 100 do
					expect(LiveRandom.new(1, 10, SEED_TO_USE):peek()).to.equal(10)
				end
			end)
			it("should return the correct value every time, even with a constant random seed", function()
				local randomSeed = (os.clock() % 1) * 1e7
				local value = LiveRandom.new(1, 10, randomSeed):peek()
				for _ = 1, 100 do
					expect(LiveRandom.new(1, 10, randomSeed):peek()).to.equal(value)
				end
			end)
			it("should not regenerate", function()
				local liveRandom = LiveRandom.new(1, 10)
				-- biome-ignore lint/suspicious/noSelfCompare: shut up
				expect(liveRandom:peek() == liveRandom:peek()).to.equal(true)
			end)
		end)
		describe("LiveRandom.rig", function()
			it("should return the same LiveRandom", function()
				local liveRandom = LiveRandom.new(1, 10)
				expect(liveRandom:rig(11)).to.equal(liveRandom)
			end)
			it("should return the rigged value on next get/peek", function()
				expect(LiveRandom.new(1, 10, SEED_TO_USE):rig(11):peek()).to.equal(11)
			end)
		end)
		describe("LiveRandom.get", function()
			it("should return a unique value in the range only once until we're out, then we repeat", function()
				local liveRandom = LiveRandom.new(1, 10)
				local first = liveRandom:peek()
				local hasSeen = {}
				for _ = 1, 10 do
					local index = liveRandom:get()
					expect(hasSeen[index] ~= nil).to.equal(false)
					hasSeen[index] = true
				end
				expect(liveRandom:get()).to.equal(first)
			end)
		end)
	end)
end
