From 70168cabccb0b8a273b5f8ea57c0da16a9bd2803 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Thu, 14 Apr 2011 14:30:14 -0700 Subject: [PATCH] Add the minimum unit tests. --- tests/run.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/run.js diff --git a/tests/run.js b/tests/run.js new file mode 100644 index 0000000..9c3c0b1 --- /dev/null +++ b/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.');