Adds test infrastructure for JS optimizer. Adds simple tests

This commit is contained in:
Alexey Andreev
2016-03-22 13:30:11 +03:00
parent a7fcbb614d
commit af7ddb4572
21 changed files with 473 additions and 2 deletions
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}