2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-04-29 02:57:30 +00:00
|
|
|
import { assertEquals } from "@std/assert";
|
2023-06-12 03:47:03 +00:00
|
|
|
import { parse } from "./parse.ts";
|
2024-01-23 04:04:12 +00:00
|
|
|
import { lessThan } from "./less_than.ts";
|
2023-06-12 03:47:03 +00:00
|
|
|
|
|
|
|
Deno.test({
|
2024-01-23 04:04:12 +00:00
|
|
|
name: "lessThan()",
|
2023-06-12 03:47:03 +00:00
|
|
|
fn: async (t) => {
|
|
|
|
// [version1, version2]
|
|
|
|
// version1 should be greater than version2
|
|
|
|
const versions: [string, string][] = [
|
|
|
|
["0.0.0", "0.0.0-foo"],
|
|
|
|
["0.0.1", "0.0.0"],
|
|
|
|
["1.0.0", "0.9.9"],
|
|
|
|
["0.10.0", "0.9.0"],
|
|
|
|
["0.99.0", "0.10.0"],
|
|
|
|
["2.0.0", "1.2.3"],
|
|
|
|
["1.2.3", "1.2.3-asdf"],
|
|
|
|
["1.2.3", "1.2.3-4"],
|
|
|
|
["1.2.3", "1.2.3-4-foo"],
|
|
|
|
["1.2.3-5-foo", "1.2.3-5"], // numbers < strings, `5-foo` is a string not a number
|
|
|
|
["1.2.3-5", "1.2.3-4"],
|
|
|
|
["1.2.3-5-foo", "1.2.3-5-Foo"],
|
|
|
|
["3.0.0", "2.7.2+asdf"],
|
|
|
|
["1.2.3-a.10", "1.2.3-a.5"],
|
|
|
|
["1.2.3-a.b", "1.2.3-a.5"],
|
|
|
|
["1.2.3-a.b", "1.2.3-a"],
|
|
|
|
["1.2.3-a.b.c.10.d.5", "1.2.3-a.b.c.5.d.100"],
|
|
|
|
["1.2.3-r2", "1.2.3-r100"],
|
|
|
|
["1.2.3-r100", "1.2.3-R2"],
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const [v0, v1] of versions) {
|
2024-02-29 04:00:20 +00:00
|
|
|
await t.step(`${v0} < ${v1}`, () => {
|
2023-06-12 03:47:03 +00:00
|
|
|
const s0 = parse(v0);
|
|
|
|
const s1 = parse(v1);
|
2024-01-23 04:04:12 +00:00
|
|
|
const actual = lessThan(s0, s1);
|
2024-02-29 04:00:20 +00:00
|
|
|
assertEquals(actual, false);
|
2023-06-12 03:47:03 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|