Skip to content

Commit

Permalink
Add the minimum unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariya Hidayat committed Apr 14, 2011
1 parent 6503620 commit 70168ca
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/run.js
@@ -0,0 +1,45 @@
/*global system:true, fs:true, Reflect:true */
system.print('Running unit tests for HammerJS...');

var total = 0;

function assert(passed) {
total += 1;
if (!passed) {
throw new Error('Test FAILS');
}
}

function test_fs() {
assert(typeof fs === 'function');
assert(typeof fs.exists === 'function');
assert(typeof fs.isDirectory === 'function');
assert(typeof fs.isFile === 'function');
assert(typeof fs.makeDirectory === 'function');
assert(typeof fs.list === 'function');
assert(typeof fs.open === 'function');
assert(typeof fs.workingDirectory === 'function');
}

function test_system() {
assert(typeof system === 'function');
assert(typeof system.execute === 'function');
assert(typeof system.exit === 'function');
assert(typeof system.print === 'function');
}

function test_Reflect() {
assert(typeof Reflect === 'function');
assert(typeof Reflect.parse === 'function');
}

try {
test_fs();
test_system();
test_Reflect();
} catch (e) {
system.print(e.message);
system.print(e.stack);
}

system.print('No failure. Total tests: ' + total + ' tests.');

0 comments on commit 70168ca

Please sign in to comment.