test262/implementation-contributed/javascriptcore/stress/eval-func-decl-in-eval-within-block-with-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

62 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(" { function f() { value = 20; }; }");
assert(f, 20);
}
assertThrow(() => f, "ReferenceError: Can't find variable: f");
}
for (var i = 0; i < 10000; i++){
foo();
assertThrow(() => f, "ReferenceError: Can't find variable: f");
}
function boo() {
{
var l = 20;
eval(" { function l() { value = 20; }; }");
assert(typeof l, 'function');
}
assert(typeof l, 'function');
}
for (var i = 0; i < 10000; i++){
boo();
assertThrow(() => l, "ReferenceError: Can't find variable: l");
}
function goo() {
{
let g = 20;
eval(" for(var j=0; j < 10000; j++){ function g() { }; } ");
assert(typeof g, 'number');
}
assertThrow(() => g, "ReferenceError: Can't find variable: g");
}
goo();
assertThrow(() => g, "ReferenceError: Can't find variable: g");