Commit 1cf4761d authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

qunit-vidjil.js: assert.approx(), check float 'equality'

parent 07c8f886
...@@ -8,3 +8,9 @@ QUnit.assert.includes = function(result, pattern, message ) { ...@@ -8,3 +8,9 @@ QUnit.assert.includes = function(result, pattern, message ) {
this.push(res, res, "{includes} " + pattern, message); this.push(res, res, "{includes} " + pattern, message);
} }
QUnit.assert.approx = function(result, expected, margin, message ) {
// Checks that two floats are about the same
var res = Math.abs(result-expected) <= margin
this.push(res, result, expected + "±" + margin, message);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment