MCPcopy
hub / github.com/vitest-dev/vitest / asymmetricMatch

Method asymmetricMatch

packages/expect/src/jest-asymmetric-matchers.ts:358–380  ·  view source on GitHub ↗
(other: number)

Source from the content-addressed store, hash-verified

356 }
357
358 asymmetricMatch(other: number) {
359 if (!isA('Number', other)) {
360 return false
361 }
362
363 let result = false
364 if (
365 other === Number.POSITIVE_INFINITY
366 && this.sample === Number.POSITIVE_INFINITY
367 ) {
368 result = true // Infinity - Infinity is NaN
369 }
370 else if (
371 other === Number.NEGATIVE_INFINITY
372 && this.sample === Number.NEGATIVE_INFINITY
373 ) {
374 result = true // -Infinity - -Infinity is NaN
375 }
376 else {
377 result = Math.abs(this.sample - other) < 10 ** -this.precision / 2
378 }
379 return this.inverse ? !result : result
380 }
381
382 toString() {
383 return `Number${this.inverse ? 'Not' : ''}CloseTo`

Callers

nothing calls this directly

Calls 1

isAFunction · 0.90

Tested by

no test coverage detected