deno.land / std@0.224.0 / expect / _close_to_test.ts

_close_to_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { expect } from "./expect.ts";
Deno.test("expect.closeTo()", () => { expect(0.1 + 0.2).toEqual(expect.closeTo(0.3)); expect(Math.PI).toEqual(expect.closeTo(3.14)); expect(Number.POSITIVE_INFINITY).toEqual( expect.closeTo(Number.POSITIVE_INFINITY), ); expect(Number.NEGATIVE_INFINITY).toEqual( expect.closeTo(Number.NEGATIVE_INFINITY), );
expect(0.1 + 0.2).not.toEqual(expect.closeTo(0.3, 17)); expect(0.999_999).not.toEqual(expect.closeTo(1, 10)); expect(NaN).not.toEqual(expect.closeTo(NaN)); expect(Number.POSITIVE_INFINITY).not.toEqual( expect.closeTo(Number.NEGATIVE_INFINITY), );});
std

Version Info

Tagged at
6 months ago