From 815913a982cb95133e7d5afbf5b1349376a05a64 Mon Sep 17 00:00:00 2001
From: Ross Kirsling <rkirsling@gmail.com>
Date: Fri, 4 Jan 2019 21:31:36 -0800
Subject: [PATCH] Test update for proposed Annex B.3.5 simplification

---
 .../var-env-lower-lex-catch-non-strict.js     | 11 ++++----
 .../try/catch-redeclared-for-in-var.js        |  5 ++--
 .../try/catch-redeclared-for-of-var.js        | 27 +++++++++++++++++++
 .../try/catch-redeclared-for-var.js           |  7 +++--
 .../var-env-lower-lex-catch-non-strict.js     | 21 ---------------
 5 files changed, 38 insertions(+), 33 deletions(-)
 create mode 100644 test/annexB/language/statements/try/catch-redeclared-for-of-var.js
 delete mode 100644 test/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js

diff --git a/test/annexB/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js b/test/annexB/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js
index ff82e2c9ad..928d9b6cf5 100644
--- a/test/annexB/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js
+++ b/test/annexB/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js
@@ -9,16 +9,12 @@ info: |
 
     This modified behaviour also applies to var and function declarations
     introduced by direct evals contained within the Block of a Catch clause.
-    This change is accomplished by modify the algorithm of 18.2.1.2 as follows:
+    This change is accomplished by modifying the algorithm of 18.2.1.3 as follows:
 
     Step 5.d.ii.2.a.i is replaced by:
 
     i. If thisEnvRec is not the Environment Record for a Catch clause, throw a
        SyntaxError exception.
-    ii. If name is bound by any syntactic form other than a
-        FunctionDeclaration, a VariableStatement, the VariableDeclarationList
-        of a for statement, or the ForBinding of a for-in statement, throw a
-        SyntaxError exception.
 flags: [noStrict]
 ---*/
 
@@ -26,7 +22,12 @@ try {
   throw null;
 } catch (err) {
   eval('function err() {}');
+  eval('function* err() {}');
+  eval('async function err() {}');
+  eval('async function* err() {}');
+
   eval('var err;');
   eval('for (var err; false; ) {}');
   eval('for (var err in []) {}');
+  eval('for (var err of []) {}');
 }
diff --git a/test/annexB/language/statements/try/catch-redeclared-for-in-var.js b/test/annexB/language/statements/try/catch-redeclared-for-in-var.js
index e2a2022eb3..7bcd2317ab 100644
--- a/test/annexB/language/statements/try/catch-redeclared-for-in-var.js
+++ b/test/annexB/language/statements/try/catch-redeclared-for-in-var.js
@@ -6,9 +6,8 @@ es6id: B.3.5
 description: Re-declaration of catch parameter (for-in statement)
 info: |
     It is a Syntax Error if any element of the BoundNames of CatchParameter
-    also occurs in the VarDeclaredNames of Block, unless that element is only
-    bound by a VariableStatement or the VariableDeclarationList of a for
-    statement, or the ForBinding of a for-in statement.
+    also occurs in the VarDeclaredNames of Block, unless CatchParameter is
+    CatchParameter : BindingIdentifier.
 ---*/
 
 var before, during, after;
diff --git a/test/annexB/language/statements/try/catch-redeclared-for-of-var.js b/test/annexB/language/statements/try/catch-redeclared-for-of-var.js
new file mode 100644
index 0000000000..c66f548461
--- /dev/null
+++ b/test/annexB/language/statements/try/catch-redeclared-for-of-var.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-variablestatements-in-catch-blocks
+es6id: B.3.5
+description: Re-declaration of catch parameter (for-of statement)
+info: |
+    It is a Syntax Error if any element of the BoundNames of CatchParameter
+    also occurs in the VarDeclaredNames of Block, unless CatchParameter is
+    CatchParameter : BindingIdentifier.
+---*/
+
+var before, during, after;
+
+try {
+  throw 'exception';
+} catch (err) {
+  before = err;
+  for (var err of [2]) {
+    during = err;
+  }
+  after = err;
+}
+
+assert.sameValue(before, 'exception');
+assert.sameValue(during, 2, 'during loop body evaluation');
+assert.sameValue(after, 2, 'after loop body evaluation');
diff --git a/test/annexB/language/statements/try/catch-redeclared-for-var.js b/test/annexB/language/statements/try/catch-redeclared-for-var.js
index ab289f26f7..437924b417 100644
--- a/test/annexB/language/statements/try/catch-redeclared-for-var.js
+++ b/test/annexB/language/statements/try/catch-redeclared-for-var.js
@@ -3,12 +3,11 @@
 /*---
 esid: sec-variablestatements-in-catch-blocks
 es6id: B.3.5
-description: Re-declaration of catch parameter (for-in statement)
+description: Re-declaration of catch parameter (for statement)
 info: |
     It is a Syntax Error if any element of the BoundNames of CatchParameter
-    also occurs in the VarDeclaredNames of Block, unless that element is only
-    bound by a VariableStatement or the VariableDeclarationList of a for
-    statement, or the ForBinding of a for-in statement.
+    also occurs in the VarDeclaredNames of Block, unless CatchParameter is
+    CatchParameter : BindingIdentifier.
 ---*/
 
 var before, during, after;
diff --git a/test/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js b/test/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js
deleted file mode 100644
index f69029fdb4..0000000000
--- a/test/language/eval-code/direct/var-env-lower-lex-catch-non-strict.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (C) 2016 the V8 project authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-/*---
-esid: sec-evaldeclarationinstantiation
-es6id: 18.2.1.2
-description: Variable collision with lexical binding in lower scope
-info: |
-    Annex B extensions permit re-declarations from FunctionDeclaration,
-    VariableStatement, the VariableDeclarationList of a for statement, and the
-    ForBinding of a for-in statement. Bindings from the ForBinding of a for-of
-    statement are restricted regardless of the application of Annex B.
-flags: [noStrict]
----*/
-
-assert.throws(SyntaxError, function() {
-  try {
-    throw null;
-  } catch (err) {
-    eval('for (var err of []) {}');
-  }
-});
-- 
GitLab