Adds test infrastructure for JS optimizer. Adds simple tests
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
function test(n) {
|
||||
var result;
|
||||
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"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
function test(n) {
|
||||
var result;
|
||||
var $tmp;
|
||||
if (n >= 0) {
|
||||
$tmp = n;
|
||||
}
|
||||
else {
|
||||
$tmp = -n;
|
||||
}
|
||||
|
||||
result = $tmp;
|
||||
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"
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
function test(n) {
|
||||
var result;
|
||||
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"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
function test(n) {
|
||||
var $tmp;
|
||||
if (n >= 0) {
|
||||
$tmp = n;
|
||||
}
|
||||
else {
|
||||
$tmp = -n;
|
||||
}
|
||||
var result = $tmp;
|
||||
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"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
function test(n) {
|
||||
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"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
function test(n) {
|
||||
var $tmp;
|
||||
if (n >= 0) {
|
||||
$tmp = n;
|
||||
}
|
||||
else {
|
||||
$tmp = -n;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
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