deno.land / std@0.224.0 / semver / range_max_test.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280// Copyright Isaac Z. Schlueter and Contributors. All rights reserved. ISC license.// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { parseRange } from "./parse_range.ts";import { rangeMax } from "./range_max.ts";import { INVALID } from "./constants.ts";import type { SemVer } from "./types.ts";import { assertEquals } from "../assert/assert_equals.ts";
Deno.test({ name: "rangeMax()", fn: async (t) => { const versions: [string, SemVer][] = [ ["=1.0.0", { major: 1, minor: 0, patch: 0, prerelease: [], build: [] }], ["1.0.0", { major: 1, minor: 0, patch: 0, prerelease: [], build: [] }], ["1.0", { major: 1, minor: 0, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["1", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["1.0.x", { major: 1, minor: 0, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["1.x.x", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["1.x", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["1.0.*", { major: 1, minor: 0, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["1.*.*", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["1.*", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["*", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["1.*.x", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["1.x.*", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["~1.1.1", { major: 1, minor: 1, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["~1.1.1-beta", { major: 1, minor: 1, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["^1.1.1", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], ["^1.1.1-beta", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["1.1.1 - 1.8.0", { major: 1, minor: 8, patch: 0, prerelease: [], build: [], }], ["1.1 - 1.8.0", { major: 1, minor: 8, patch: 0, prerelease: [], build: [], }], ["1.1.1 - 1.8", { major: 1, minor: 8, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["<1.0.0", { build: [], major: 0, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], }], ["<1.0.0-0", { build: [], major: 0, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], }], ["<1.0.0-beta", { build: [], major: 0, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], }],
[">1.0.0", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], [">1.0.0-0", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], [">1.0.0-beta", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["<0.0.0-beta", INVALID], [">0.0.0-beta", { build: [], major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], }], ["<0.0.1-beta", { major: 0, minor: 0, patch: 0, prerelease: [], build: [], }], [">0.0.1-beta", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["<2 || >4", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], [">=4 || <=2", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
[">=1.1.1 <2 || >=2.2.2 <2", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], [">=2.2.2 <2 || >=1.1.1 <2", { major: 1, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
[">2 || >1.0.0", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], [">2 || >1.0.0-0", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }], [">2 || >1.0.0-beta", { major: Number.POSITIVE_INFINITY, minor: Number.POSITIVE_INFINITY, patch: Number.POSITIVE_INFINITY, prerelease: [], build: [], }],
["<0.0.0-beta >0.0.0-alpha", INVALID], [">0.0.0-alpha <0.0.0-beta", INVALID], [">4 <3", INVALID], ];
for (const [version, expected] of versions) { await t.step(version, () => { const actual = rangeMax(parseRange(version)); assertEquals(actual, expected); }); } },});
Version Info