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

distinct_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
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../testing/asserts.ts";import { distinct } from "./distinct.ts";
function distinctTest<I>( input: Array<I>, expected: Array<I>, message?: string,) { const actual = distinct(input); assertEquals(actual, expected, message);}
Deno.test({ name: "[collections/distinct] identities on empty array", fn() { distinctTest([], []); },});
Deno.test({ name: "[collections/distinct] removes duplicates and preserves order", fn() { distinctTest( [true, "asdf", 4, "asdf", true], [true, "asdf", 4], ); distinctTest( [null, undefined, null, "foo", undefined], [null, undefined, "foo"], ); distinctTest( [true, "asdf", 4, "asdf", true], [true, "asdf", 4], ); },});
Deno.test({ name: "[collections/distinct] does not check for deep equality", fn() { const objects = [{ foo: "bar" }, { foo: "bar" }]; distinctTest(objects, objects);
const arrays = [[], []]; distinctTest(arrays, arrays);
const nans = [NaN, NaN]; distinctTest(nans, [nans[0]]);
const noops = [() => {}, () => {}]; distinctTest(noops, noops);
const sets = [new Set(), new Set()]; distinctTest(sets, sets); },});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago