mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 22:40:28 +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)
64 lines
2.0 KiB
JavaScript
64 lines
2.0 KiB
JavaScript
function foo(o, p) {
|
|
var x = 100;
|
|
var result = 101;
|
|
var pf = p.g;
|
|
try {
|
|
x = 102;
|
|
pf++;
|
|
result = o.f;
|
|
o = 104;
|
|
pf++;
|
|
x = 106;
|
|
} catch (e) {
|
|
return {outcome: "exception", values: [o, pf, x, result]};
|
|
}
|
|
return {outcome: "return", values: [o, pf, x, result]};
|
|
}
|
|
|
|
noInline(foo);
|
|
|
|
// Warm up foo() with polymorphic objects and non-object types.
|
|
for (var i = 0; i < 100000; ++i) {
|
|
var o;
|
|
var isObject = i & 1;
|
|
if (isObject) {
|
|
o = {f:107};
|
|
o["i" + i] = i; // Make it polymorphic.
|
|
} else
|
|
o = 42;
|
|
var result = foo(o, {g:200});
|
|
if (result.outcome !== "return")
|
|
throw "Error in loop: bad outcome: " + result.outcome;
|
|
if (result.values.length !== 4)
|
|
throw "Error in loop: bad number of values: " + result.values.length;
|
|
if (result.values[0] !== 104)
|
|
throw "Error in loop: bad values[0]: " + result.values[0];
|
|
if (result.values[1] !== 202)
|
|
throw "Error in loop: bad values[1]: " + result.values[1];
|
|
if (result.values[2] !== 106)
|
|
throw "Error in loop: bad values[2]: " + result.values[2];
|
|
if (isObject) {
|
|
if (result.values[3] !== 107)
|
|
throw "Error in loop: bad values[3]: " + result.values[3];
|
|
} else {
|
|
if (result.values[3] !== void 0)
|
|
throw "Error in loop: bad values[3]: " + result.values[3];
|
|
}
|
|
}
|
|
|
|
// Now throw an exception.
|
|
var result = foo(null, {g:300});
|
|
if (result.outcome !== "exception")
|
|
throw "Error at end: bad outcome: " + result.outcome;
|
|
if (result.values.length !== 4)
|
|
throw "Error at end: bad number of values: " + result.values.length;
|
|
if (result.values[0] !== null)
|
|
throw "Error at end: bad values[0]: " + result.values[0];
|
|
if (result.values[1] !== 301)
|
|
throw "Error at end: bad values[1]: " + result.values[1];
|
|
if (result.values[2] !== 102)
|
|
throw "Error at end: bad values[2]: " + result.values[2];
|
|
if (result.values[3] !== 101)
|
|
throw "Error at end: bad values[3]: " + result.values[3];
|
|
|