import "@js-temporal/polyfill";
import "urlpattern-polyfill";
globalThis.addEventListener = () => {};
import { t as test } from "../testing-BQeTO4ss.mjs";
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
import "../std__assert-2v7gYiZp.mjs";
import { t as assertThrows } from "../assert_throws-BIL7gChy.mjs";
import { n as parseSemVer, t as formatSemVer } from "../semver-CgD82xxg.mjs";
//#region src/nodeinfo/semver.test.ts
test("parseSemVer() handles major", async (t) => {
	for (const [v, expected] of [
		["1.2.3", 1],
		[" 1.2.3 ", 1],
		[" 2.2.3-4 ", 2],
		[" 3.2.3-pre ", 3],
		["v5.2.3", 5],
		[" v8.2.3 ", 8],
		["	13.2.3", 13]
	]) await t.step(v, () => {
		assertEquals(parseSemVer(v).major, expected);
	});
});
test("parseSemVer() handles minor", async (t) => {
	for (const [v, expected] of [
		["1.1.3", 1],
		[" 1.1.3 ", 1],
		[" 1.2.3-4 ", 2],
		[" 1.3.3-pre ", 3],
		["v1.5.3", 5],
		[" v1.8.3 ", 8],
		["	1.13.3", 13]
	]) await t.step(v, () => {
		assertEquals(parseSemVer(v).minor, expected);
	});
});
test("parseSemVer() handles patch", async (t) => {
	for (const [v, expected] of [
		["1.2.1", 1],
		[" 1.2.1 ", 1],
		[" 1.2.2-4 ", 2],
		[" 1.2.3-pre ", 3],
		["v1.2.5", 5],
		[" v1.2.8 ", 8],
		["	1.2.13", 13]
	]) await t.step(v, () => {
		const actual = parseSemVer(v).patch;
		assertEquals(actual, expected);
	});
});
test("parseSemVer() handles prerelease", async (t) => {
	for (const [v, expected] of [
		["1.2.2-alpha.1", ["alpha", 1]],
		["0.6.1-1", [1]],
		["1.0.0-beta.2", ["beta", 2]],
		["v0.5.4-pre", ["pre"]],
		["1.2.2-alpha.1", ["alpha", 1]],
		["1.2.0-1b3-4", ["1b3-4"]],
		["1.2.0-3.6-pre2", [3, "6-pre2"]],
		["2.0.0", []]
	]) await t.step(`${v} : ${JSON.stringify(expected)}`, () => {
		assertEquals(parseSemVer(v).prerelease, expected);
	});
});
test({
	name: "parseSemVer() throws on bad versions",
	fn: async (t) => {
		const versions = [
			["1.2." + new Array(256).join("1")],
			["1.2." + new Array(100).join("1")],
			[null],
			[void 0],
			[{}],
			[[]],
			[false],
			[true],
			[0],
			[""],
			["not a version"],
			["∞.∞.∞"],
			["NaN.NaN.NaN"]
		];
		for (const [v] of versions) await t.step(`${JSON.stringify(v)}`, () => {
			assertThrows(() => parseSemVer(v));
		});
	}
});
test("parseSemVer() throws on invalid versions", async (t) => {
	for (const v of [
		"1.2.3.4",
		"NOT VALID",
		1.2,
		null,
		"Infinity.NaN.Infinity"
	]) await t.step(`invalid ${v}`, () => {
		assertThrows(function() {
			parseSemVer(v);
		}, TypeError);
	});
});
test("parseSemVer() handles big numeric prerelease", function() {
	assertEquals(parseSemVer(`1.2.3-beta.${Number.MAX_SAFE_INTEGER}0`).prerelease, ["beta", "90071992547409910"]);
});
test("formatSemVer()", async (t) => {
	for (const [version, expected] of [
		["0.0.0", "0.0.0"],
		["1.2.3", "1.2.3"],
		["1.2.3-pre", "1.2.3-pre"],
		["1.2.3-pre.0", "1.2.3-pre.0"],
		["1.2.3+b", "1.2.3+b"],
		["1.2.3+b.0", "1.2.3+b.0"],
		["1.2.3-pre.0+b.0", "1.2.3-pre.0+b.0"]
	]) await t.step({
		name: version,
		fn: () => {
			assertEquals(formatSemVer(parseSemVer(version)), expected);
		}
	});
});
//#endregion
export {};
