Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: tools/cc-frame-viewer/third_party/gl-matrix/spec/helpers/spec-helper.js

Issue 12251005: [cc-frame-viewer] Add gl-matrix to third_party [redux] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 var HELPER_MATCHERS = (function() {
2 var EPSILON = 0.00001;
3
4 return {
5 /*
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.
10 */
11 toBeEqualish: function(expected) {
12 if (typeof(this.actual) == 'number')
13 return Math.abs(this.actual - expected) < EPSILON;
14
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]))
18 return false;
19 if (Math.abs(this.actual[i] - expected[i]) >= EPSILON)
20 return false;
21 }
22 return true;
23 }
24 };
25 })();
26
27 beforeEach(function() {
28 this.addMatchers(HELPER_MATCHERS);
29 });
30
31 if (typeof(global) != 'undefined')
32 global.HELPER_MATCHERS = HELPER_MATCHERS;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698