mirror of
https://github.com/tc39/test262.git
synced 2025-05-02 22:10:34 +02:00
* [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)
79 lines
1.9 KiB
JavaScript
79 lines
1.9 KiB
JavaScript
var hasBasicBlockExecuted = $vm.hasBasicBlockExecuted;
|
|
|
|
load("./driver/driver.js");
|
|
|
|
function forRegular(limit) {
|
|
var sum = 0;
|
|
for (var i = 0; i < limit; i++) {
|
|
sum += i;
|
|
}
|
|
|
|
return sum;
|
|
}
|
|
|
|
function forIn(o) {
|
|
var s = "";
|
|
var p;
|
|
for (p in o) {
|
|
s += p;
|
|
}
|
|
}
|
|
|
|
function forOf(a) {
|
|
var s = "";
|
|
var p;
|
|
for (p of a) {
|
|
s += p;
|
|
}
|
|
}
|
|
|
|
function whileLoop(limit) {
|
|
var i = 0;
|
|
var sum = 0;
|
|
while (i < limit) {
|
|
sum += i;
|
|
i++;
|
|
}
|
|
|
|
return sum;
|
|
}
|
|
|
|
assert(!hasBasicBlockExecuted(forRegular, "var sum"), "should not have executed yet.");
|
|
|
|
forRegular(0);
|
|
assert(hasBasicBlockExecuted(forRegular, "var sum"), "should have executed.");
|
|
assert(!hasBasicBlockExecuted(forRegular, "sum += i"), "should not have executed yet.");
|
|
|
|
forRegular(1);
|
|
assert(hasBasicBlockExecuted(forRegular, "sum += i"), "should have executed.");
|
|
|
|
|
|
assert(!hasBasicBlockExecuted(forIn, "var s"), "should not have executed yet.");
|
|
|
|
forIn({});
|
|
assert(hasBasicBlockExecuted(forIn, "var s"), "should have executed.");
|
|
assert(!hasBasicBlockExecuted(forIn, "s += p"), "should not have executed yet.");
|
|
|
|
forIn({foo: "bar"});
|
|
assert(hasBasicBlockExecuted(forIn, "s += p"), "should have executed.");
|
|
|
|
|
|
assert(!hasBasicBlockExecuted(forOf, "var s"), "should not have executed yet.");
|
|
|
|
forOf([]);
|
|
assert(hasBasicBlockExecuted(forOf, "var s"), "should have executed.");
|
|
assert(!hasBasicBlockExecuted(forOf, "s += p"), "should not have executed yet.");
|
|
|
|
forOf(["a"]);
|
|
assert(hasBasicBlockExecuted(forOf, "s += p"), "should have executed.");
|
|
|
|
|
|
assert(!hasBasicBlockExecuted(whileLoop, "var sum"), "should not have executed yet.");
|
|
|
|
whileLoop(0);
|
|
assert(hasBasicBlockExecuted(whileLoop, "var sum"), "should have executed.");
|
|
assert(!hasBasicBlockExecuted(whileLoop, "sum += i"), "should not have executed yet.");
|
|
|
|
whileLoop(1);
|
|
assert(hasBasicBlockExecuted(whileLoop, "sum += i"), "should have executed.");
|