run.js
1.13 KB
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
var PATH = system.script.replace(/tests(\/|\\)run.js/, '');
load(PATH + 'src/Loader.js');
Loader.setBasePath(PATH + 'src');
Loader.require([
'Ext',
'Cli',
'Logger'
]);
var assertTrue = function(message, a) {
assertEqual(message, a, true);
};
var assertFalse = function(message, a) {
assertEqual(message, a, false);
};
var assertEqual = function(message, a, b) {
if ((Ext.isArray(a) || Ext.isObject(a)) && (Ext.isArray(b) || Ext.isObject(b))) {
a = JSON.stringify(a);
b = JSON.stringify(b);
}
Logger.log("[" + ((a === b) ? "PASSED" : "FAILED") + "] " + message);
};
var assertNotEqual = function(message, a, b) {
assertEqual(message, a, !b);
};
var Tester = Ext.extend(Cli, {
name: "Super simple Unit Tester",
version: "1.0",
map: {
n: {
name: 'name',
required: true,
desc: 'Name of the test you want to run, e.g Parser'
}
},
run: function() {
if (Tester.superclass.run.call(this) === false)
return;
load(PATH + 'tests/'+this.get('name')+'.js');
}
});
var tester = new Tester();
tester.run();