Bug 1146136 - Followup to condition tests using |super| syntax on class syntax being enabled. r=bustage in a CLOSED TREE
authorJeff Walden <jwalden@mit.edu>
Mon, 29 Jun 2015 15:45:02 -0700
changeset 268676 dc9b15c377e993aced491f8d878ef6da0dcc73a2
parent 268675 633cc765aa62bb23e5b2cd2f7019d47007614138
child 268677 42f1bdd8b0dac58b0676e1b3232c746ffddaf96d
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1146136
milestone41.0a2
Bug 1146136 - Followup to condition tests using |super| syntax on class syntax being enabled. r=bustage in a CLOSED TREE
js/src/tests/ecma_6/Expressions/destructuring-pattern-parenthesized.js
--- a/js/src/tests/ecma_6/Expressions/destructuring-pattern-parenthesized.js
+++ b/js/src/tests/ecma_6/Expressions/destructuring-pattern-parenthesized.js
@@ -77,19 +77,36 @@ Function("var a, b; [(arguments) = 5, b]
 Function("var a, b; [(eval), b] = [1, 2];")();
 Function("var a, b; [(eval) = 5, b] = [1, 2];")();
 
 var repair = {}, demolition = {};
 
 Function("var a, b; [(repair.man), b] = [1, 2];")();
 Function("var a, b; [(demolition['man']) = 'motel', b] = [1, 2];")();
 Function("var a, b; [(demolition['man' + {}]) = 'motel', b] = [1, 2];")(); // evade constant-folding
-Function("var a, b; var obj = { x() { [(super.man), b] = [1, 2]; } };")();
-Function("var a, b; var obj = { x() { [(super[8]) = 'motel', b] = [1, 2]; } };")();
-Function("var a, b; var obj = { x() { [(super[8 + {}]) = 'motel', b] = [1, 2]; } };")(); // evade constant-folding
+
+function classesEnabled()
+{
+  try
+  {
+    new Function("class B { constructor() { } }; class D extends B { constructor() { super(); } }");
+    return true;
+  }
+  catch (e if e instanceof SyntaxError)
+  {
+    return false;
+  }
+}
+
+if (classesEnabled())
+{
+  Function("var a, b; var obj = { x() { [(super.man), b] = [1, 2]; } };")();
+  Function("var a, b; var obj = { x() { [(super[8]) = 'motel', b] = [1, 2]; } };")();
+  Function("var a, b; var obj = { x() { [(super[8 + {}]) = 'motel', b] = [1, 2]; } };")(); // evade constant-folding
+}
 
 // In strict mode, assignment to funcall *immediately* triggers ReferenceError
 // before we can recognize this doesn't even match the destructuring grammar to
 // begin with.  Bleh.  :-(  Probably they should all be made SyntaxError in the
 // specs; see <https://bugs.ecmascript.org/show_bug.cgi?id=4375>.
 checkError("var a, b; [f() = 'ohai', b] = [1, 2];", SyntaxError, ReferenceError);
 checkError("var a, b; [(f()) = 'kthxbai', b] = [1, 2];", SyntaxError, ReferenceError);