test262/implementation-contributed/javascriptcore/stress/eval-func-decl-within-eval-without-reassign-to-let.js
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

61 lines
1.5 KiB
JavaScript

var assert = function (result, expected, message) {
if (result !== expected) {
throw new Error('Error in assert. Expected "' + expected + '" but was "' + result + '":' + message );
}
};
var assertThrow = function (cb, expected) {
let error = null;
try {
cb();
} catch(e) {
error = e;
}
if (error === null) {
throw new Error('Error is expected. Expected "' + expected + '" but error was not thrown."');
}
if (error.toString() !== expected) {
throw new Error('Error is expected. Expected "' + expected + '" but error was "' + error + '"');
}
};
function foo() {
{
let f = 20;
eval('eval(" { function f() { }; } ")');
assert(f, 20);
}
assert(typeof f, "undefined", "#1");
}
for (var i = 0; i < 10000; i++){
foo();
assertThrow(() => f, "ReferenceError: Can't find variable: f");
}
function boo() {
{
var l = 20;
eval('eval(" { function l() { }; } ")');
assert(typeof l, 'function', "#3");
}
assert(typeof l, 'function', "#4");
}
for (var i = 0; i < 10000; i++){
boo();
assertThrow(() => l, "ReferenceError: Can't find variable: l");
}
function goo() {
{
let g = 20;
eval('eval(" for(var j=0; j < 10000; j++){ function g() { }; } ")');
assert(typeof g, 'number', "#6");
}
assertThrow(() => g, "ReferenceError: Can't find variable: g");
}
goo();
assertThrow(() => g, "ReferenceError: Can't find variable: g");