Bug 1273858 - Testcases draft
authorTed Campbell <tcampbell@mozilla.com>
Thu, 16 Feb 2017 22:51:18 -0500
changeset 488107 e0cfbc4ab638e67c70fa20544c0d89afabd074e7
parent 488106 8ffe2fe1729098c7641e587415ce23f3daa264f1
child 546638 ddaf2415d8769d3b5ee73346be350102f43543e5
push id46423
push userbmo:tcampbell@mozilla.com
push dateWed, 22 Feb 2017 15:41:44 +0000
bugs1273858
milestone54.0a1
Bug 1273858 - Testcases MozReview-Commit-ID: AasrybVpMgN
js/src/jit-test/tests/ion/bug1273858-1.js
js/src/jit-test/tests/ion/bug1273858-2.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug1273858-1.js
@@ -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();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug1273858-2.js
@@ -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();