eq

说明

比较两个值是否全等(NaNtrue)

源码

用法

eq.test.ts
1
import { eq } from "../../utility/others/eq";
2
3
describe('eq tests: ', () => {
4
test('eq should return true or false when receive two basic value that equals', () => {
5
const received = [100, 100];
6
const expected = true;
7
8
const result = eq(received[0], received[1]);
9
10
expect(result).toBe(expected);
11
});
12
13
test('eq should return false when receive two object but point at different memory', () => {
14
const received = [{}, {}];
15
const expected = false;
16
17
const result = eq(received[0], received[1]);
18
19
expect(result).toBe(expected);
20
});
21
22
test('eq should return true when receive two object point at same memory', () => {
23
const obj = {};
24
25
const received = [obj, obj];
26
const expected = true;
27
28
const result = eq(received[0], received[1]);
29
30
expect(result).toBe(expected);
31
});
32
33
test('eq should return true when receive two NaN value', () => {
34
const received = [NaN, NaN];
35
const expected = true;
36
37
const result = eq(received[0], received[1]);
38
39
expect(result).toBe(expected);
40
});
41
});
Copied!
最近更新 1yr ago
复制链接