1 var HELPER_MATCHERS = (function() {
6 Returns true if `actual` has the same length as `expected`, and
7 if each element of both arrays is within 0.000001 of each other.
8 This is a way to check for "equal enough" conditions, as a way
9 of working around floating point imprecision.
11 toBeEqualish: function(expected) {
12 if (typeof(this.actual) == 'number')
13 return Math.abs(this.actual - expected) < EPSILON;
15 if (this.actual.length != expected.length) return false;
16 for (var i = 0; i < this.actual.length; i++) {
17 if (isNaN(this.actual[i]) !== isNaN(expected[i]))
19 if (Math.abs(this.actual[i] - expected[i]) >= EPSILON)
27 beforeEach(function() {
28 this.addMatchers(HELPER_MATCHERS);
31 if (typeof(global) != 'undefined')
32 global.HELPER_MATCHERS = HELPER_MATCHERS;