Adds test infrastructure for JS optimizer. Adds simple tests
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
function test(n) {
|
||||
var result;
|
||||
result = n >= 0 ? n : -n;
|
||||
return result;
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(20);
|
||||
if (result != 20) return "fail1: " + result;
|
||||
|
||||
result = test(-20);
|
||||
if (result != 20) return "fail2: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
function test(n) {
|
||||
var result;
|
||||
/*synthetic*/ if (n >= 0) {
|
||||
result = n;
|
||||
}
|
||||
else {
|
||||
result = -n;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(20);
|
||||
if (result != 20) return "fail1: " + result;
|
||||
|
||||
result = test(-20);
|
||||
if (result != 20) return "fail2: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
function test(n) {
|
||||
return n >= 0 ? n : -n;
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(20);
|
||||
if (result != 20) return "fail1: " + result;
|
||||
|
||||
result = test(-20);
|
||||
if (result != 20) return "fail2: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
function test(n) {
|
||||
/*synthetic*/ if (n >= 0) {
|
||||
return n;
|
||||
}
|
||||
else {
|
||||
return -n;
|
||||
}
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(20);
|
||||
if (result != 20) return "fail1: " + result;
|
||||
|
||||
result = test(-20);
|
||||
if (result != 20) return "fail2: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user