Bug 1273858 - Testcases r=jandem

MozReview-Commit-ID: AasrybVpMgN

--HG--
extra : rebase_source : b311f7aac944f2468b5d6cfd357c0308f934f589
This commit is contained in:
Ted Campbell 2017-02-16 22:51:18 -05:00
Родитель 9f630025f0
Коммит 2fe8cd4877
2 изменённых файлов: 99 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,53 @@
// |jit-test| --no-threads
function t1() {
let x = [];
for (let k = 0; k < 100; ++k)
x[k] = () => k; // Lexical capture
try {
eval("k");
throw false;
}
catch (e) {
if (!(e instanceof ReferenceError))
throw "Loop index escaped block";
}
for (var i = 0; i < 100; ++i)
if (x[i]() != i)
throw "Bad let capture";
}
t1();
t1();
t1();
t1();
function t2() {
let x = [];
let y = {};
for (var i = 0; i < 100; ++i)
x[i] = i;
for (const k of x)
y[k] = () => k; // Lexical capture
try {
eval("k");
throw false;
}
catch (e) {
if (!(e instanceof ReferenceError))
throw "Loop index escaped block";
}
for (var i = 0; i < 100; ++i)
if (y[i]() != i)
throw "Bad const capture";
}
t2();
t2();
t2();
t2();

Просмотреть файл

@ -0,0 +1,46 @@
// |jit-test| --no-threads
function t1() {
let x = [];
try
{
for (let k = 0; k < 100; ++k)
{
let w = () => k; // Lexical capture
if (w() > 10)
{
throw () => w; // Lexical capture
}
x[k] = w;
}
}
catch (e)
{
// 'w' and 'k' should leave scope as exception unwinds
try {
eval("k");
throw false;
}
catch (e) {
if (!(e instanceof ReferenceError))
throw "Loop index escaped block";
}
try {
eval("w");
throw false;
}
catch (e) {
if (!(e instanceof ReferenceError))
throw "Local name escaped block";
}
}
}
t1();
t1();
t1();
t1();