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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/cc-frame-viewer/third_party/gl-matrix/spec/helpers/spec-helper.js
diff --git a/tools/cc-frame-viewer/third_party/gl-matrix/spec/helpers/spec-helper.js b/tools/cc-frame-viewer/third_party/gl-matrix/spec/helpers/spec-helper.js
new file mode 100644
index 0000000000000000000000000000000000000000..58e367145052933bbd9fd29affd27e378a170cd2
--- /dev/null
+++ b/tools/cc-frame-viewer/third_party/gl-matrix/spec/helpers/spec-helper.js
@@ -0,0 +1,32 @@
+var HELPER_MATCHERS = (function() {
+ var EPSILON = 0.00001;
+
+ return {
+ /*
+ Returns true if `actual` has the same length as `expected`, and
+ if each element of both arrays is within 0.000001 of each other.
+ This is a way to check for "equal enough" conditions, as a way
+ of working around floating point imprecision.
+ */
+ toBeEqualish: function(expected) {
+ if (typeof(this.actual) == 'number')
+ return Math.abs(this.actual - expected) < EPSILON;
+
+ if (this.actual.length != expected.length) return false;
+ for (var i = 0; i < this.actual.length; i++) {
+ if (isNaN(this.actual[i]) !== isNaN(expected[i]))
+ return false;
+ if (Math.abs(this.actual[i] - expected[i]) >= EPSILON)
+ return false;
+ }
+ return true;
+ }
+ };
+})();
+
+beforeEach(function() {
+ this.addMatchers(HELPER_MATCHERS);
+});
+
+if (typeof(global) != 'undefined')
+ global.HELPER_MATCHERS = HELPER_MATCHERS;

Powered by Google App Engine
This is Rietveld 408576698