forked from wisec/DOMinator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTest.js
More file actions
46 lines (36 loc) · 755 Bytes
/
UnitTest.js
File metadata and controls
46 lines (36 loc) · 755 Bytes
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
var assertsOk=[];
var assertsKo=[];
var GREEN="\033[5;34;42m"
var RED="\033[1;37;41m"
var BLACK="\033[00m"
function isTrue(msg){
return GREEN+msg+BLACK;
}
function isFalse(msg){
return RED+msg+BLACK;
}
function assert(msg,arg,exp){
try{
var res = eval.call(this,arg);
if(exp == null){
exp = true;
}
if( res == exp){
print(isTrue(msg+arg));
assertsOk.push(msg+arg);
} else {
print(isFalse(msg+arg));
assertsKo.push(msg+arg);
}
}catch(e){
print(isFalse(msg+arg+' Exc:'+e));
assertsKo.push(msg+arg);
}
}
function printResults(){
print("[Ok] "+assertsOk.join("\n"));
if(assertsKo.length>0)
print("[Ko] "+assertsKo.join(" "));
else
print("Congratulations! All tests were correct");
}