mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 21:32:05 +00:00
Remove unused semver functions from Bun's implementation
This commit is contained in:
26
packages/bun-types/bun.d.ts
vendored
26
packages/bun-types/bun.d.ts
vendored
@@ -4896,15 +4896,7 @@ declare module "bun" {
|
||||
*/
|
||||
function intersects(range1: StringLike, range2: StringLike): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the sub range is entirely contained within the super range.
|
||||
*/
|
||||
function subset(sub: StringLike, dom: StringLike): boolean;
|
||||
|
||||
/**
|
||||
* Returns the minimum version that can satisfy the given range, or null if none.
|
||||
*/
|
||||
function minVersion(range: StringLike): string | null;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the highest version in the list that satisfies the range, or null if none of them do.
|
||||
@@ -4916,21 +4908,7 @@ declare module "bun" {
|
||||
*/
|
||||
function minSatisfying(versions: StringLike[], range: StringLike): string | null;
|
||||
|
||||
/**
|
||||
* Returns true if version is greater than all the versions possible in the range.
|
||||
*/
|
||||
function gtr(version: StringLike, range: StringLike): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if version is less than all the versions possible in the range.
|
||||
*/
|
||||
function ltr(version: StringLike, range: StringLike): boolean;
|
||||
|
||||
/**
|
||||
* Determines if version is outside the bounds of the range in either the high or low direction.
|
||||
* The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||
*/
|
||||
function outside(version: StringLike, range: StringLike, hilo?: "<" | ">"): string | false;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a simplified range expression that matches the same items in the versions list as the input range.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
const object = JSC.JSValue.createEmptyObject(globalThis, 18);
|
||||
const object = JSC.JSValue.createEmptyObject(globalThis, 13);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
@@ -109,30 +109,6 @@ pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
),
|
||||
);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
JSC.ZigString.static("subset"),
|
||||
JSC.host_fn.NewFunction(
|
||||
globalThis,
|
||||
JSC.ZigString.static("subset"),
|
||||
2,
|
||||
SemverObject.subset,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
JSC.ZigString.static("minVersion"),
|
||||
JSC.host_fn.NewFunction(
|
||||
globalThis,
|
||||
JSC.ZigString.static("minVersion"),
|
||||
1,
|
||||
SemverObject.minVersion,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
JSC.ZigString.static("maxSatisfying"),
|
||||
@@ -157,42 +133,6 @@ pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
),
|
||||
);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
JSC.ZigString.static("gtr"),
|
||||
JSC.host_fn.NewFunction(
|
||||
globalThis,
|
||||
JSC.ZigString.static("gtr"),
|
||||
2,
|
||||
SemverObject.gtr,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
JSC.ZigString.static("ltr"),
|
||||
JSC.host_fn.NewFunction(
|
||||
globalThis,
|
||||
JSC.ZigString.static("ltr"),
|
||||
2,
|
||||
SemverObject.ltr,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
JSC.ZigString.static("outside"),
|
||||
JSC.host_fn.NewFunction(
|
||||
globalThis,
|
||||
JSC.ZigString.static("outside"),
|
||||
3,
|
||||
SemverObject.outside,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
object.put(
|
||||
globalThis,
|
||||
JSC.ZigString.static("simplifyRange"),
|
||||
@@ -555,77 +495,12 @@ pub fn intersects(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bu
|
||||
const g2 = Query.parse(allocator, r2_slice.slice(), SlicedString.init(r2_slice.slice(), r2_slice.slice())) catch return JSC.jsBoolean(false);
|
||||
defer g2.deinit();
|
||||
|
||||
// Assuming Group.intersects is implemented
|
||||
return JSC.jsBoolean(g1.intersects(&g2, r1_slice.slice(), r2_slice.slice()));
|
||||
}
|
||||
|
||||
pub fn subset(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
|
||||
defer arena.deinit();
|
||||
var stack_fallback = std.heap.stackFallback(2048, arena.allocator());
|
||||
const allocator = stack_fallback.get();
|
||||
|
||||
const arguments = callFrame.arguments_old(2).slice();
|
||||
if (arguments.len < 2) return JSC.jsBoolean(false);
|
||||
|
||||
// Check if both arguments are strings
|
||||
if (!arguments[0].isString() or !arguments[1].isString()) {
|
||||
return JSC.jsBoolean(false);
|
||||
}
|
||||
|
||||
const sub_str = try arguments[0].toJSString(globalThis);
|
||||
const sub_slice = sub_str.toSlice(globalThis, allocator);
|
||||
defer sub_slice.deinit();
|
||||
|
||||
const super_str = try arguments[1].toJSString(globalThis);
|
||||
const super_slice = super_str.toSlice(globalThis, allocator);
|
||||
defer super_slice.deinit();
|
||||
|
||||
// Check for empty strings
|
||||
if (sub_slice.slice().len == 0 or super_slice.slice().len == 0) {
|
||||
return JSC.jsBoolean(false);
|
||||
}
|
||||
|
||||
// Simplified implementation - always returns true for now
|
||||
return JSC.jsBoolean(true);
|
||||
}
|
||||
|
||||
pub fn minVersion(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
|
||||
defer arena.deinit();
|
||||
var stack_fallback = std.heap.stackFallback(1024, arena.allocator());
|
||||
const allocator = stack_fallback.get();
|
||||
|
||||
const arguments = callFrame.arguments_old(1).slice();
|
||||
if (arguments.len < 1) return JSC.JSValue.null;
|
||||
|
||||
// Check if the argument is a string
|
||||
if (!arguments[0].isString()) {
|
||||
return JSC.JSValue.null;
|
||||
}
|
||||
|
||||
const range_str = try arguments[0].toJSString(globalThis);
|
||||
const range_slice = range_str.toSlice(globalThis, allocator);
|
||||
defer range_slice.deinit();
|
||||
|
||||
const query = Query.parse(allocator, range_slice.slice(), SlicedString.init(range_slice.slice(), range_slice.slice())) catch return JSC.JSValue.null;
|
||||
defer query.deinit();
|
||||
|
||||
// Check if it's an exact version
|
||||
if (query.getExactVersion()) |exact| {
|
||||
// Format the exact version
|
||||
const formatted = try std.fmt.allocPrint(allocator, "{d}.{d}.{d}", .{ exact.major, exact.minor, exact.patch });
|
||||
return bun.String.createUTF8ForJS(globalThis, formatted);
|
||||
}
|
||||
|
||||
// Check if the query has any meaningful content
|
||||
if (!query.head.head.range.hasLeft()) {
|
||||
return JSC.JSValue.null;
|
||||
}
|
||||
|
||||
// For other ranges, return 0.0.0 as a simple implementation
|
||||
return bun.String.static("0.0.0").toJS(globalThis);
|
||||
}
|
||||
|
||||
fn findSatisfyingVersion(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
@@ -731,138 +606,7 @@ pub fn minSatisfying(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame)
|
||||
return findSatisfyingVersion(globalThis, versions_array, range_slice.slice(), allocator, false);
|
||||
}
|
||||
|
||||
pub fn gtr(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
|
||||
defer arena.deinit();
|
||||
var stack_fallback = std.heap.stackFallback(1024, arena.allocator());
|
||||
const allocator = stack_fallback.get();
|
||||
|
||||
const arguments = callFrame.arguments_old(2).slice();
|
||||
if (arguments.len < 2) return JSC.jsBoolean(false);
|
||||
|
||||
// Check if both arguments are strings
|
||||
if (!arguments[0].isString() or !arguments[1].isString()) {
|
||||
return JSC.jsBoolean(false);
|
||||
}
|
||||
|
||||
const version_str = try arguments[0].toJSString(globalThis);
|
||||
const version_slice = version_str.toSlice(globalThis, allocator);
|
||||
defer version_slice.deinit();
|
||||
|
||||
const range_str = try arguments[1].toJSString(globalThis);
|
||||
const range_slice = range_str.toSlice(globalThis, allocator);
|
||||
defer range_slice.deinit();
|
||||
|
||||
if (!strings.isAllASCII(version_slice.slice())) return JSC.jsBoolean(false);
|
||||
|
||||
const parse_result = Version.parse(SlicedString.init(version_slice.slice(), version_slice.slice()));
|
||||
if (!parse_result.valid) return JSC.jsBoolean(false);
|
||||
|
||||
const query = (Query.parse(allocator, range_slice.slice(), SlicedString.init(range_slice.slice(), range_slice.slice())) catch return JSC.jsBoolean(false));
|
||||
defer query.deinit();
|
||||
|
||||
// Check if version is greater than all versions in the range
|
||||
// Simplified implementation - always returns false
|
||||
return JSC.jsBoolean(false);
|
||||
}
|
||||
|
||||
pub fn ltr(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
|
||||
defer arena.deinit();
|
||||
var stack_fallback = std.heap.stackFallback(1024, arena.allocator());
|
||||
const allocator = stack_fallback.get();
|
||||
|
||||
const arguments = callFrame.arguments_old(2).slice();
|
||||
if (arguments.len < 2) return JSC.jsBoolean(false);
|
||||
|
||||
// Check if both arguments are strings
|
||||
if (!arguments[0].isString() or !arguments[1].isString()) {
|
||||
return JSC.jsBoolean(false);
|
||||
}
|
||||
|
||||
const version_str = try arguments[0].toJSString(globalThis);
|
||||
const version_slice = version_str.toSlice(globalThis, allocator);
|
||||
defer version_slice.deinit();
|
||||
|
||||
const range_str = try arguments[1].toJSString(globalThis);
|
||||
const range_slice = range_str.toSlice(globalThis, allocator);
|
||||
defer range_slice.deinit();
|
||||
|
||||
if (!strings.isAllASCII(version_slice.slice())) return JSC.jsBoolean(false);
|
||||
|
||||
const parse_result = Version.parse(SlicedString.init(version_slice.slice(), version_slice.slice()));
|
||||
if (!parse_result.valid) return JSC.jsBoolean(false);
|
||||
|
||||
const query = (Query.parse(allocator, range_slice.slice(), SlicedString.init(range_slice.slice(), range_slice.slice())) catch return JSC.jsBoolean(false));
|
||||
defer query.deinit();
|
||||
|
||||
// Check if version is less than all versions in the range
|
||||
// Simplified implementation - always returns false
|
||||
return JSC.jsBoolean(false);
|
||||
}
|
||||
|
||||
pub fn outside(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
|
||||
defer arena.deinit();
|
||||
var stack_fallback = std.heap.stackFallback(1024, arena.allocator());
|
||||
const allocator = stack_fallback.get();
|
||||
|
||||
const arguments = callFrame.arguments_old(3).slice();
|
||||
if (arguments.len < 2) return JSC.JSValue.null;
|
||||
|
||||
// Check if first two arguments are strings
|
||||
if (!arguments[0].isString() or !arguments[1].isString()) {
|
||||
return JSC.JSValue.null;
|
||||
}
|
||||
|
||||
const version_str = try arguments[0].toJSString(globalThis);
|
||||
const version_slice = version_str.toSlice(globalThis, allocator);
|
||||
defer version_slice.deinit();
|
||||
|
||||
const range_str = try arguments[1].toJSString(globalThis);
|
||||
const range_slice = range_str.toSlice(globalThis, allocator);
|
||||
defer range_slice.deinit();
|
||||
|
||||
// Default to ">" if third argument is missing
|
||||
var hilo: []const u8 = ">";
|
||||
if (arguments.len >= 3 and arguments[2].isString()) {
|
||||
const hilo_str = try arguments[2].toJSString(globalThis);
|
||||
const hilo_slice = hilo_str.toSlice(globalThis, allocator);
|
||||
defer hilo_slice.deinit();
|
||||
hilo = hilo_slice.slice();
|
||||
|
||||
if (!strings.eql(hilo, "<") and !strings.eql(hilo, ">")) {
|
||||
return globalThis.throw("Third argument must be '<' or '>'", .{});
|
||||
}
|
||||
}
|
||||
|
||||
if (!strings.isAllASCII(version_slice.slice())) return JSC.JSValue.null;
|
||||
const parse_result = Version.parse(SlicedString.init(version_slice.slice(), version_slice.slice()));
|
||||
if (!parse_result.valid) return JSC.JSValue.null;
|
||||
|
||||
const version = parse_result.version.min();
|
||||
const query = (Query.parse(allocator, range_slice.slice(), SlicedString.init(range_slice.slice(), range_slice.slice())) catch {
|
||||
// If range parsing fails, return false
|
||||
return JSC.jsBoolean(false);
|
||||
});
|
||||
defer query.deinit();
|
||||
|
||||
// Returns true if version is outside the range in the specified direction
|
||||
const does_satisfy = query.satisfies(version, range_slice.slice(), version_slice.slice());
|
||||
if (does_satisfy) {
|
||||
return JSC.jsBoolean(false);
|
||||
}
|
||||
|
||||
// Check if version is less than or greater than the range
|
||||
// This is a simplified implementation
|
||||
if (strings.eql(hilo, "<")) {
|
||||
// For now, assume if it doesn't satisfy and hilo is "<", version is less
|
||||
return bun.String.createUTF8ForJS(globalThis, "<");
|
||||
} else {
|
||||
// For now, assume if it doesn't satisfy and hilo is ">", version is greater
|
||||
return bun.String.createUTF8ForJS(globalThis, ">");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simplifyRange(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
|
||||
|
||||
@@ -976,31 +976,7 @@ describe("Bun.semver.intersects()", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Bun.semver.subset()", () => {
|
||||
test("returns true for any subset check", () => {
|
||||
// Note: Simplified implementation always returns true
|
||||
expect(Bun.semver.subset("^1.2.0", "^1.0.0")).toBe(true);
|
||||
expect(Bun.semver.subset("~1.2.3", "^1.2.0")).toBe(true);
|
||||
expect(Bun.semver.subset("1.2.3", "^1.0.0")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Bun.semver.minVersion()", () => {
|
||||
test("returns exact version for exact ranges", () => {
|
||||
expect(Bun.semver.minVersion("1.2.3")).toBe("1.2.3");
|
||||
expect(Bun.semver.minVersion("=1.2.3")).toBe("1.2.3");
|
||||
});
|
||||
|
||||
test("returns 0.0.0 for other ranges", () => {
|
||||
expect(Bun.semver.minVersion("^1.0.0")).toBe("0.0.0");
|
||||
expect(Bun.semver.minVersion("~1.2.0")).toBe("0.0.0");
|
||||
expect(Bun.semver.minVersion(">=1.0.0")).toBe("0.0.0");
|
||||
});
|
||||
|
||||
test("returns null for invalid ranges", () => {
|
||||
expect(Bun.semver.minVersion("not-a-range")).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Bun.semver.maxSatisfying()", () => {
|
||||
test("finds the highest satisfying version", () => {
|
||||
@@ -1038,48 +1014,7 @@ describe("Bun.semver.minSatisfying()", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Bun.semver.gtr()", () => {
|
||||
test("always returns false in simplified implementation", () => {
|
||||
expect(Bun.semver.gtr("2.0.0", "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.gtr("1.0.0", "<1.0.0")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for invalid versions", () => {
|
||||
expect(Bun.semver.gtr("invalid", "^1.0.0")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Bun.semver.ltr()", () => {
|
||||
test("always returns false in simplified implementation", () => {
|
||||
expect(Bun.semver.ltr("0.1.0", "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.ltr("2.0.0", ">2.0.0")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for invalid versions", () => {
|
||||
expect(Bun.semver.ltr("invalid", "^1.0.0")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Bun.semver.outside()", () => {
|
||||
test("returns false if version satisfies range", () => {
|
||||
expect(Bun.semver.outside("1.2.0", "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.outside("1.2.0", "^1.0.0", "<")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns direction if version doesn't satisfy", () => {
|
||||
// Default hilo is ">", so it returns ">" when version doesn't satisfy
|
||||
expect(Bun.semver.outside("0.1.0", "^1.0.0")).toBe(">");
|
||||
expect(Bun.semver.outside("0.1.0", "^1.0.0", ">")).toBe(">");
|
||||
});
|
||||
|
||||
test("throws for invalid hilo argument", () => {
|
||||
expect(() => Bun.semver.outside("1.0.0", "^1.0.0", "invalid" as any)).toThrow("Third argument must be '<' or '>'");
|
||||
});
|
||||
|
||||
test("returns null for invalid version", () => {
|
||||
expect(Bun.semver.outside("invalid", "^1.0.0")).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Bun.semver.simplifyRange()", () => {
|
||||
test("simplifies OR'd exact versions to tilde range", () => {
|
||||
@@ -1270,36 +1205,7 @@ describe("Bun.semver negative tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("subset() negative tests", () => {
|
||||
test("returns false for non-string inputs", () => {
|
||||
expect(Bun.semver.subset(123 as any, "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.subset("^1.0.0", 123 as any)).toBe(false);
|
||||
expect(Bun.semver.subset(null as any, "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.subset("^1.0.0", null as any)).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for invalid range strings", () => {
|
||||
expect(Bun.semver.subset("", "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.subset("^1.0.0", "")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("minVersion() negative tests", () => {
|
||||
test("returns null for non-string inputs", () => {
|
||||
expect(Bun.semver.minVersion(123 as any)).toBe(null);
|
||||
expect(Bun.semver.minVersion(null as any)).toBe(null);
|
||||
expect(Bun.semver.minVersion(undefined as any)).toBe(null);
|
||||
expect(Bun.semver.minVersion({} as any)).toBe(null);
|
||||
expect(Bun.semver.minVersion([] as any)).toBe(null);
|
||||
});
|
||||
|
||||
test("returns null for invalid range strings", () => {
|
||||
expect(Bun.semver.minVersion("")).toBe(null);
|
||||
expect(Bun.semver.minVersion("not-a-range")).toBe(null);
|
||||
expect(Bun.semver.minVersion("@#$%")).toBe(null);
|
||||
expect(Bun.semver.minVersion("!!!")).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("maxSatisfying() negative tests", () => {
|
||||
test("throws for non-array first argument", () => {
|
||||
@@ -1348,69 +1254,7 @@ describe("Bun.semver negative tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("gtr() negative tests", () => {
|
||||
test("returns false for non-string inputs", () => {
|
||||
expect(Bun.semver.gtr(123 as any, "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.gtr("1.0.0", 123 as any)).toBe(false);
|
||||
expect(Bun.semver.gtr(null as any, "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.gtr("1.0.0", null as any)).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for invalid version strings", () => {
|
||||
expect(Bun.semver.gtr("", "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.gtr("not-a-version", "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.gtr("1.2.3.4", "^1.0.0")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for invalid range strings", () => {
|
||||
expect(Bun.semver.gtr("1.0.0", "")).toBe(false);
|
||||
expect(Bun.semver.gtr("1.0.0", "not-a-range")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ltr() negative tests", () => {
|
||||
test("returns false for non-string inputs", () => {
|
||||
expect(Bun.semver.ltr(123 as any, "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.ltr("1.0.0", 123 as any)).toBe(false);
|
||||
expect(Bun.semver.ltr(null as any, "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.ltr("1.0.0", null as any)).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for invalid version strings", () => {
|
||||
expect(Bun.semver.ltr("", "^1.0.0")).toBe(false);
|
||||
expect(Bun.semver.ltr("not-a-version", "^1.0.0")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("outside() negative tests", () => {
|
||||
test("returns null for non-string version/range inputs", () => {
|
||||
expect(Bun.semver.outside(123 as any, "^1.0.0", ">")).toBe(null);
|
||||
expect(Bun.semver.outside("1.0.0", 123 as any, ">")).toBe(null);
|
||||
expect(Bun.semver.outside(null as any, "^1.0.0", ">")).toBe(null);
|
||||
expect(Bun.semver.outside("1.0.0", null as any, ">")).toBe(null);
|
||||
});
|
||||
|
||||
test("throws for invalid hilo values", () => {
|
||||
expect(() => Bun.semver.outside("1.0.0", "^1.0.0", "invalid" as any)).toThrow();
|
||||
expect(() => Bun.semver.outside("1.0.0", "^1.0.0", "" as any)).toThrow();
|
||||
// null hilo defaults to ">"
|
||||
expect(Bun.semver.outside("1.0.0", "^1.0.0", null as any)).toBe(false);
|
||||
// 123 defaults to ">"
|
||||
expect(Bun.semver.outside("1.0.0", "^1.0.0", 123 as any)).toBe(false);
|
||||
});
|
||||
|
||||
test("returns null for invalid version strings", () => {
|
||||
expect(Bun.semver.outside("", "^1.0.0", ">")).toBe(null);
|
||||
expect(Bun.semver.outside("not-a-version", "^1.0.0", ">")).toBe(null);
|
||||
});
|
||||
|
||||
test("returns null for invalid range strings", () => {
|
||||
// Empty range returns false
|
||||
expect(Bun.semver.outside("1.0.0", "", ">")).toBe(false);
|
||||
// "not-a-range" is parsed as an exact version requirement
|
||||
expect(Bun.semver.outside("1.0.0", "not-a-range", ">")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("simplifyRange() negative tests", () => {
|
||||
test("throws for non-array first argument", () => {
|
||||
@@ -1520,23 +1364,12 @@ describe("Bun.semver negative tests", () => {
|
||||
expect((Bun.semver.bump as any)("1.2.3")).toBe(null);
|
||||
expect((Bun.semver.intersects as any)()).toBe(false);
|
||||
expect((Bun.semver.intersects as any)("^1.0.0")).toBe(false);
|
||||
expect((Bun.semver.subset as any)()).toBe(false);
|
||||
expect((Bun.semver.subset as any)("^1.0.0")).toBe(false);
|
||||
expect((Bun.semver.minVersion as any)()).toBe(null);
|
||||
// Returns null when called without arguments
|
||||
expect((Bun.semver.maxSatisfying as any)()).toBe(null);
|
||||
expect((Bun.semver.maxSatisfying as any)(["1.0.0"])).toBe(null);
|
||||
// Returns null when called without arguments
|
||||
expect((Bun.semver.minSatisfying as any)()).toBe(null);
|
||||
expect((Bun.semver.minSatisfying as any)(["1.0.0"])).toBe(null);
|
||||
expect((Bun.semver.gtr as any)()).toBe(false);
|
||||
expect((Bun.semver.gtr as any)("1.0.0")).toBe(false);
|
||||
expect((Bun.semver.ltr as any)()).toBe(false);
|
||||
expect((Bun.semver.ltr as any)("1.0.0")).toBe(false);
|
||||
expect((Bun.semver.outside as any)()).toBe(null);
|
||||
expect((Bun.semver.outside as any)("1.0.0")).toBe(null);
|
||||
// Returns ">" when called with 2 arguments (default hilo)
|
||||
expect((Bun.semver.outside as any)("1.0.0", "^1.0.0")).toBe(false);
|
||||
expect((Bun.semver.simplifyRange as any)()).toBe(null);
|
||||
expect((Bun.semver.simplifyRange as any)(["1.0.0"])).toBe(null);
|
||||
expect((Bun.semver.validRange as any)()).toBe(null);
|
||||
|
||||
Reference in New Issue
Block a user