-
Notifications
You must be signed in to change notification settings - Fork 10
/
runTests.js
55 lines (45 loc) · 1.13 KB
/
runTests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
/**
* Run package tests.
* (C) 2013 Alex Fernández.
*/
// requires
var testing = require('testing');
/**
* Test that new objects, strings, arrays, numbers
* and regular expressions have no enumerable properties.
*/
function testObjectsAreClean(callback)
{
assertIsClean({}, callback);
assertIsClean('', callback);
assertIsClean([], callback);
assertIsClean(41.5, callback);
assertIsClean(/abc/, callback);
testing.success(callback);
}
function assertIsClean(newObject, callback) {
for (var key in newObject) {
testing.failure('New object %j has enumerable property %s', newObject, key, callback);
}
}
/**
* Run all module tests.
*/
exports.test = function(callback)
{
var tests = {};
tests.objectsAreCleanBeforeLoadingLibrary = testObjectsAreClean;
var files = [ 'core', 'string', 'array', 'math', 'object' ];
files.forEach(function(file)
{
tests[file] = require('./test/' + file + '.js').test;
});
tests.objectsAreCleanAfterLoadingLibrary = testObjectsAreClean;
testing.run(tests, callback);
};
// run tests if invoked directly
if (__filename == process.argv[1])
{
exports.test(testing.show);
}