-
Notifications
You must be signed in to change notification settings - Fork 19
/
semver_test.ts
42 lines (36 loc) · 980 Bytes
/
semver_test.ts
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
42
import { Semver } from "./semver.ts";
import { assert, assertEquals, assertThrows } from "./test_deps.ts";
Deno.test("semver", () => {
const v = new Semver("1.0.2");
assertEquals(v.major, 1);
assertEquals(v.minor, 0);
assertEquals(v.patch, 2);
});
Deno.test("semverEq", () => {
const v1 = new Semver("1.0.2");
assert(v1.eq(v1));
});
Deno.test("SemverLt", () => {
const v1 = new Semver("1.0.2");
const v2 = new Semver("1.0.3");
assert(v1.lt(v2));
});
Deno.test("semverTilde", () => {
const v1 = new Semver("1.0.2");
const v2 = new Semver("1.0.3");
assert(v1.tilde(v2));
});
Deno.test("semverBad", () => {
assertThrows(() => new Semver("bad.0.2"));
});
Deno.test("semverToken", () => {
const v1 = new Semver("1.0.2");
const v2 = new Semver("1.0.3");
assert(v1._("<", v2));
assert(v1._("<=", v2));
assert(v1._("~", v2));
assert(!v1._("=", v2));
assert(!v1._(">=", v2));
assert(!v1._(">", v2));
assertThrows(() => v1._("x", v2));
});