forked from aantthony/javascript-cas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
78 lines (75 loc) · 1.87 KB
/
test.js
File metadata and controls
78 lines (75 loc) · 1.87 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env node
var sys = require('sys');
var exec = require('child_process').exec;
exec('make', function(err, stdout, stderr){
var stderr = process.stderr,
stdout = process.stdout;
var M = require('./build/math.js');
function color(str){
return '\x1b[1m' + (str || "") + '\x1b[22m';
}
function _(){
//console.log(" ----");
}
function assert(cond){
if(!cond){
throw(new Error("Assertion Failed."));
}
}
function run(){
var i,l;
for(i=0,l=arguments.length;i<l;i++){
stdout.write(color("Test: "+ (arguments[i].name.replace('_',' ') || i+1))+"\n");
arguments[i]();
//console.log("------");
}
}
//console.log(M("3"));
console.log("------");
run(
function three(){
M(" 3 ");
},
function Simple_Addition(){
M("3 + x");
},
function Equality(){
M("x=2");
},
function Parenthesis(){
console.log("A");
M("(1)");
console.log("B");
M("3/(2)");
console.log("C");
M("3+(x)/[((5))]");
//M("3/(+2)");
},
function Mutlicharacter_Operators(){
//M("x++");
},
function Implied_Multiplication(){
M("2x");
_();
M("x x");
_();
M(" x(x)");
_();
M("(x)x");
_();
assert(M("(3)2").value == 6);
},
function Numerical(){
assert(M("0.4").value == 0.4);
assert(M("3+2").value == 5);
assert(M("3-5").value == -2);
},
function Complex_Numerical(){
assert(M("i").toString() === "i");
assert(M("i*i").toString() === "-1");
//assert(M("i^2").toString() === "-1 + 0i");
},
function Complex(){
}
);
})