import { expect, test, vi } from "vitest" import { randomBoolean } from "#Source/random/index.ts" test("randomBoolean returns expected output across probabilities and available random sources", () => { const defaultValue = randomBoolean() expect(typeof defaultValue).toBe("boolean") expect(randomBoolean(0)).toBe(false) expect(randomBoolean(1)).toBe(true) expect(() => randomBoolean(Number.NaN)).toThrow(TypeError) expect(() => randomBoolean(Number.POSITIVE_INFINITY)).toThrow(TypeError) expect(() => randomBoolean(-0.1)).toThrow(RangeError) expect(() => randomBoolean(1.1)).toThrow(RangeError) vi.stubGlobal("crypto", undefined) try { const fallbackValue = randomBoolean(0.5) expect(typeof fallbackValue).toBe("boolean") } finally { vi.unstubAllGlobals() } })