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

min_of_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { minOf } from "./min_of.ts";import { assertEquals } from "../testing/asserts.ts";
Deno.test("[collections/minOf] Regular min", () => { const array = [5, 18, 35, 120];
const actual = minOf(array, (i) => i); assertEquals(actual, 5);});
Deno.test("[collections/minOf] Mixed negatives and positives numbers", () => { const array = [-32, -18, 140, 36];
const actual = minOf(array, (i) => i); assertEquals(actual, -32);});
Deno.test("[collections/minOf] Negatives numbers", () => { const array = [-32, -18, -140, -36];
const actual = minOf(array, (i) => i); assertEquals(actual, -140);});
Deno.test("[collections/minOf] BigInt regular min", () => { const array = [BigInt(5), BigInt(18), BigInt(35), BigInt(120)];
const actual = minOf(array, (i) => i); assertEquals(actual, BigInt(5));});
Deno.test("[collections/minOf] BigInt negatives numbers", () => { const array = [BigInt(-32), BigInt(-18), BigInt(-140), BigInt(-36)];
const actual = minOf(array, (i) => i); assertEquals(actual, BigInt(-140));});
Deno.test("[collection/minOf] On object properties", () => { const object = [ { name: "mustard", count: 2 }, { name: "soy", count: 4 }, { name: "tomato", count: 32 }, ];
const actual = minOf(object, (i) => i.count); assertEquals(actual, 2);});
Deno.test("[collection/minOf] On mixed object properties", () => { const object = [ { name: "mustard", count: -2 }, { name: "soy", count: 4 }, { name: "tomato", count: -32 }, ];
const actual = minOf(object, (i) => i.count); assertEquals(actual, -32);});
Deno.test("[collections/minOf] No mutation", () => { const array = [1, 2, 3, 4];
minOf(array, (i) => i + 2);
assertEquals(array, [1, 2, 3, 4]);});
Deno.test("[collections/minOf] Empty array results in undefined", () => { const array: number[] = [];
const actual = minOf(array, (i) => i); assertEquals(actual, undefined);});
Deno.test("[collections/minOf] NaN and Infinity", () => { const array = [ 1, 2, Number.POSITIVE_INFINITY, 3, 4, Number.NEGATIVE_INFINITY, 5, 6, Number.NaN, 7, 8, ];
const actual = minOf(array, (i) => i); assertEquals(actual, NaN);});
Deno.test("[collections/minOf] Minus infinity", () => { const array = [1, 2, -Infinity, 3, 4, 5, 6, 7, 8];
const actual = minOf(array, (i) => i);
assertEquals(actual, -Infinity);});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago