deno.land / std@0.166.0 / collections / _comparators_test.ts

_comparators_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
43
44
45
46
47
48
49
50
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { assertEquals } from "../testing/asserts.ts";import { ascend, descend } from "./_comparators.ts";
Deno.test("[collections/comparators] ascend", () => { assertEquals(ascend(2, 2), 0); assertEquals(ascend(2, 3), -1); assertEquals(ascend(3, 2), 1); assertEquals(ascend("b", "b"), 0); assertEquals(ascend("a", "b"), -1); assertEquals(ascend("b", "a"), 1); assertEquals(ascend("b", "b0"), -1); assertEquals(ascend("b0", "b"), 1); assertEquals(ascend("2020-05-20", "2020-05-20"), 0); assertEquals(ascend("2020-05-19", "2020-05-20"), -1); assertEquals(ascend("2020-05-20", "2020-05-19"), 1); assertEquals(ascend(new Date("2020-05-20"), new Date("2020-05-20")), 0); assertEquals(ascend(new Date("2020-05-19"), new Date("2020-05-20")), -1); assertEquals(ascend(new Date("2020-05-20"), new Date("2020-05-19")), 1); assertEquals(ascend<string | number>(-10, "-10"), 0); assertEquals(ascend<string | number>("-10", -10), 0); assertEquals(ascend<string | number>(-9, "-10"), 1); assertEquals(ascend<string | number>("-9", -10), 1); assertEquals(ascend<string | number>(-10, "-9"), -1); assertEquals(ascend<string | number>("-10", -9), -1);});
Deno.test("[collections/comparators] descend", () => { assertEquals(descend(2, 2), 0); assertEquals(descend(2, 3), 1); assertEquals(descend(3, 2), -1); assertEquals(descend("b", "b"), 0); assertEquals(descend("a", "b"), 1); assertEquals(descend("b", "a"), -1); assertEquals(descend("b", "b0"), 1); assertEquals(descend("b0", "b"), -1); assertEquals(descend("2020-05-20", "2020-05-20"), 0); assertEquals(descend("2020-05-19", "2020-05-20"), 1); assertEquals(descend("2020-05-20", "2020-05-19"), -1); assertEquals(descend(new Date("2020-05-20"), new Date("2020-05-20")), 0); assertEquals(descend(new Date("2020-05-19"), new Date("2020-05-20")), 1); assertEquals(descend(new Date("2020-05-20"), new Date("2020-05-19")), -1); assertEquals(descend<string | number>(-10, "-10"), 0); assertEquals(descend<string | number>("-10", -10), 0); assertEquals(descend<string | number>(-9, "-10"), -1); assertEquals(descend<string | number>("-9", -10), -1); assertEquals(descend<string | number>(-10, "-9"), 1); assertEquals(descend<string | number>("-10", -9), 1);});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago