test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

142 lines
3.1 KiB
JavaScript

function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
function above(a, trap) {
let result = 0;
for (let i = 0; (a >>> 0) > (i >>> 0); ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(above);
function aboveOrEqual(a, trap) {
let result = 0;
for (let i = 0; (a >>> 0) >= (i >>> 0); ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(aboveOrEqual);
function below(a, trap) {
let result = 0;
for (let i = 0; (i >>> 0) < (a >>> 0); ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(below);
function belowOrEqual(a, trap) {
let result = 0;
for (let i = 0; (i >>> 0) <= (a >>> 0); ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(belowOrEqual);
function notAbove(a, trap) {
let result = 0;
for (let i = 0; (a >>> 0) > (i >>> 0) && a; ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(notAbove);
function notAboveOrEqual(a, trap) {
let result = 0;
for (let i = 0; (a >>> 0) >= (i >>> 0) && a; ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(notAboveOrEqual);
function notBelow(a, trap) {
let result = 0;
for (let i = 0; (i >>> 0) < (a >>> 0) && a; ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(notBelow);
function notBelowOrEqual(a, trap) {
let result = 0;
for (let i = 0; (i >>> 0) <= (a >>> 0) && a; ++i) {
result += i;
if (i === trap)
break;
}
return result;
}
noInline(notBelowOrEqual);
for (var i = 0; i < 1e2; ++i) {
shouldBe(above(0, -1), 0);
shouldBe(above(20000, -1), 199990000);
shouldBe(above(-1, 10000), 50005000);
}
for (var i = 0; i < 1e2; ++i) {
shouldBe(aboveOrEqual(0, -1), 0);
shouldBe(aboveOrEqual(20000, -1), 200010000);
shouldBe(aboveOrEqual(-1, 10000), 50005000);
}
for (var i = 0; i < 1e2; ++i) {
shouldBe(below(0, -1), 0);
shouldBe(below(20000, -1), 199990000);
shouldBe(below(-1, 10000), 50005000);
}
for (var i = 0; i < 1e2; ++i) {
shouldBe(belowOrEqual(0, -1), 0);
shouldBe(belowOrEqual(20000, -1), 200010000);
shouldBe(belowOrEqual(-1, 10000), 50005000);
}
for (var i = 0; i < 1e2; ++i) {
shouldBe(notAbove(0, -1), 0);
shouldBe(notAbove(20000, -1), 199990000);
shouldBe(notAbove(-1, 10000), 50005000);
}
for (var i = 0; i < 1e2; ++i) {
shouldBe(notAboveOrEqual(0, -1), 0);
shouldBe(notAboveOrEqual(20000, -1), 200010000);
shouldBe(notAboveOrEqual(-1, 10000), 50005000);
}
for (var i = 0; i < 1e2; ++i) {
shouldBe(notBelow(0, -1), 0);
shouldBe(notBelow(20000, -1), 199990000);
shouldBe(notBelow(-1, 10000), 50005000);
}
for (var i = 0; i < 1e2; ++i) {
shouldBe(notBelowOrEqual(0, -1), 0);
shouldBe(notBelowOrEqual(20000, -1), 200010000);
shouldBe(notBelowOrEqual(-1, 10000), 50005000);
}