test("Close Numbers", function () {
+ var halfPi = Math.PI / 2,
+ sqrt2 = Math.sqrt(2);
QUnit.close(7, 7, 0);
QUnit.close(7, 7.1, 0.1);
QUnit.close(7, 7.1, 0.2);
-
+
QUnit.close(3.141, Math.PI, 0.001);
QUnit.close(3.1, Math.PI, 0.1);
-
- var halfPi = Math.PI / 2;
+
QUnit.close(halfPi, 1.57, 0.001);
-
- var sqrt2 = Math.sqrt(2);
+
QUnit.close(sqrt2, 1.4142, 0.0001);
-
- QUnit.close(Infinity, Infinity, 1);
-
+
+ QUnit.close(Infinity, Infinity, 1);
});
test("Distant Numbers", function () {
+ var halfPi = Math.PI / 2,
+ sqrt2 = Math.sqrt(2);
QUnit.notClose(6, 7, 0);
QUnit.notClose(7, 7.2, 0.1);
QUnit.notClose(7, 7.2, 0.19999999999);
-
+
QUnit.notClose(3.141, Math.PI, 0.0001);
QUnit.notClose(3.1, Math.PI, 0.001);
-
- var halfPi = Math.PI / 2;
+
QUnit.notClose(halfPi, 1.57, 0.0001);
-
- var sqrt2 = Math.sqrt(2);
+
QUnit.notClose(sqrt2, 1.4142, 0.00001);
-
- QUnit.notClose(Infinity, -Infinity, 5);
+ QUnit.notClose(Infinity, -Infinity, 5);
});
\ No newline at end of file
});
for ( var i = 0; i < suites.length; i++ ) {
- (function( suite ) {
- asyncTest( suite, function() {
- QUnit.runSuite( suite );
- });
- }( suites[i] ) );
+ QUnit.runSuite( suites[i] );
}
+
QUnit.done(function() {
this.iframe.style.display = "none";
});
},
runSuite: function( suite ) {
- this.iframe.setAttribute( "src", suite );
+ asyncTest( suite, function() {
+ QUnit.iframe.setAttribute( "src", suite );
+ });
},
initIframe: function() {
});
QUnit.testDone(function() {
- var current = QUnit.id( this.config.current.id ),
+ var i,
+ current = QUnit.id( this.config.current.id ),
children = current.children,
src = this.iframe.src;
// undo the auto-expansion of failed tests
- for ( var i = 0; i < children.length; i++ ) {
+ for ( i = 0; i < children.length; i++ ) {
if ( children[i].nodeName === "OL" ) {
children[i].style.display = "none";
}
currentTest = {
name: data.name,
failures: [],
- start: new Date
+ start: new Date()
};
// Setup default suite if no module was specified
QUnit.done(function(data) {
function ISODateString(d) {
function pad(n) {
- return n < 10 ? '0' + n : n
- };
+ return n < 10 ? '0' + n : n;
+ }
- return d.getUTCFullYear() + '-'
- + pad(d.getUTCMonth() + 1)+'-'
- + pad(d.getUTCDate()) + 'T'
- + pad(d.getUTCHours()) + ':'
- + pad(d.getUTCMinutes()) + ':'
- + pad(d.getUTCSeconds()) + 'Z'
- };
+ return d.getUTCFullYear() + '-' +
+ pad(d.getUTCMonth() + 1)+'-' +
+ pad(d.getUTCDate()) + 'T' +
+ pad(d.getUTCHours()) + ':' +
+ pad(d.getUTCMinutes()) + ':' +
+ pad(d.getUTCSeconds()) + 'Z';
+ }
// Generate XML report
- var xmlWriter = new XmlWriter({
- linebreak_at : "testsuites,testsuite,testcase,failure,system-out,system-err"
- });
+ var i, ti, fi, test, suite,
+ xmlWriter = new XmlWriter({
+ linebreak_at : "testsuites,testsuite,testcase,failure,system-out,system-err"
+ }),
+ now = new Date();
xmlWriter.start('testsuites');
- var now = new Date();
-
- for (var i = 0; i < suites.length; i++) {
- var suite = suites[i];
+ for (i = 0; i < suites.length; i++) {
+ suite = suites[i];
// Calculate time
- for (var ti = 0; ti < suite.tests.length; ti++) {
- var test = suite.tests[ti];
+ for (ti = 0; ti < suite.tests.length; ti++) {
+ test = suite.tests[ti];
test.time = (now.getTime() - test.start.getTime()) / 1000;
suite.time += test.time;
timestamp: ISODateString(now)
});
- for (var ti = 0; ti < suite.tests.length; ti++) {
- var test = suite.tests[ti];
+ for (ti = 0; ti < suite.tests.length; ti++) {
+ test = suite.tests[ti];
xmlWriter.start('testcase', {
name: test.name,
time: Math.round(test.time * 1000) / 1000
});
- for (var fi = 0; fi < test.failures.length; fi++) {
+ for (fi = 0; fi < test.failures.length; fi++) {
xmlWriter.start('failure', {type: "AssertionFailedError", message: test.failures[fi]}, true);
}
if (lineBreakAt[name] && data[data.length - 1] !== '\n') {
data.push('\n');
}
- };
+ }
function makeMap(items, delim, map) {
var i;
}
return map;
- };
+ }
function encode(text) {
var baseEntities = {
return ('' + text).replace(/[<>&\"\']/g, function(chr) {
return baseEntities[chr] || chr;
});
- };
+ }
this.start = function(name, attrs, empty) {
if (!empty) {
};
this.pi(settings.xmldecl || 'xml version="1.0" encoding="UTF-8"');
- };
+ }
})();
\ No newline at end of file
pkg: '<json:package.json>',
qunit: {
// TODO include 'test/logs.html' as well
- files: ['test/index.html']
+ qunit: 'test/index.html',
+ addons: [
+ 'addons/canvas/canvas.html',
+ 'addons/close-enough/close-enough.html',
+ 'addons/composite/composite-demo-test.html'
+ ]
},
lint: {
qunit: 'qunit/qunit.js',
+ addons: 'addons/**/*.js',
grunt: 'grunt.js'
// TODO need to figure out which warnings to fix and which to disable
- // tests: 'test/*.js'
+ // tests: 'test/test.js'
},
jshint: {
qunit: {
exports: true
}
},
- tests: {
- tests: {
- globals: {
- module: true,
- test: true,
- ok: true,
- equal: true,
- deepEqual: true,
- QUnit: true
- }
+ addons: {
+ // meh
+ options: {
+ onevar: true,
+ smarttabs: true
}
+ },
+ tests: {
}
}
});