deno.land / std@0.224.0 / semver / can_parse_test.ts

can_parse_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { assertEquals } from "../assert/mod.ts";import { canParse } from "./can_parse.ts";
Deno.test("canParse()", async (t) => { // deno-lint-ignore no-explicit-any const versions: [any, boolean][] = [ ["1.2.3", true], [" 1.2.3 ", true], [" 2.2.3-4 ", true], [" 3.2.3-pre ", true], ["v5.2.3", true], [" v8.2.3 ", true], ["\t13.2.3", true], ["1.2." + new Array(256).join("1"), false], // too long ["1.2." + new Array(100).join("1"), false], // too big [null, false], [undefined, false], [{}, false], [[], false], [false, false], [true, false], [0, false], ["", false], ["not a version", false], ["∞.∞.∞", false], ["NaN.NaN.NaN", false], ["1.2.3.4", false], ["NOT VALID", false], [1.2, false], [null, false], ["Infinity.NaN.Infinity", false], ];
for (const [v, expected] of versions) { await t.step(`${v}`, () => { assertEquals(canParse(v), expected); }); }});
std

Version Info

Tagged at
6 months ago