deno.land / std@0.224.0 / expect / _close_to_test.ts
12345678910111213141516171819202122// 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), );});
Version Info