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"
|
||||
}
|
||||
+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"
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
function test(a, b, c) {
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(2, 3, 4);
|
||||
if (result != 9) return "fail: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
function test(a, b, c) {
|
||||
var $tmp;
|
||||
$tmp = a + b;
|
||||
return $tmp + c;
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(2, 3, 4);
|
||||
if (result != 9) return "fail: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
function test(a, b, c) {
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(2, 3, 4);
|
||||
if (result != 9) return "fail: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function test(a, b, c) {
|
||||
var $tmp = a + b;
|
||||
return $tmp + c;
|
||||
}
|
||||
|
||||
function box() {
|
||||
var result = test(2, 3, 4);
|
||||
if (result != 9) return "fail: " + result;
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user