From 76001a503f99e24482decb06357a807c3b5461ad Mon Sep 17 00:00:00 2001
From: Leonardo Balter <leonardo.balter@gmail.com>
Date: Thu, 16 Mar 2017 12:58:01 -0400
Subject: [PATCH] Fix current generator templates

---
 .../default/class-decl-method.template        | 33 +++++++++++++++++++
 .../default/class-decl-static-method.template | 33 +++++++++++++++++++
 ...on.template => class-expr-method.template} | 16 ++++-----
 .../default/class-expr-static-method.template | 33 +++++++++++++++++++
 ...tatement.template => declaration.template} |  6 ++--
 .../default/expression-named.template         | 25 ++++++++++++++
 src/generators/default/expression.template    |  4 +--
 ...efinition.template => obj-method.template} |  2 +-
 ...tatement.template => declaration.template} |  0
 .../non-strict/expression-named.template      | 25 ++++++++++++++
 src/generators/non-strict/expression.template |  2 +-
 ...efinition.template => obj-method.template} |  4 +--
 12 files changed, 166 insertions(+), 17 deletions(-)
 create mode 100644 src/generators/default/class-decl-method.template
 create mode 100644 src/generators/default/class-decl-static-method.template
 rename src/generators/default/{class-method-definition.template => class-expr-method.template} (56%)
 create mode 100644 src/generators/default/class-expr-static-method.template
 rename src/generators/default/{statement.template => declaration.template} (68%)
 create mode 100644 src/generators/default/expression-named.template
 rename src/generators/default/{method-definition.template => obj-method.template} (89%)
 rename src/generators/non-strict/{statement.template => declaration.template} (100%)
 create mode 100644 src/generators/non-strict/expression-named.template
 rename src/generators/non-strict/{method-definition.template => obj-method.template} (75%)

diff --git a/src/generators/default/class-decl-method.template b/src/generators/default/class-decl-method.template
new file mode 100644
index 0000000000..ad49590307
--- /dev/null
+++ b/src/generators/default/class-decl-method.template
@@ -0,0 +1,33 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/statements/class/gen-method-
+name: Geenerator method as a ClassDeclaration element
+esid: prod-GeneratorMethod
+info: |
+  ClassElement :
+    MethodDefinition
+
+  MethodDefinition :
+    GeneratorMethod
+
+  14.4 Generator Function Definitions
+
+  GeneratorMethod :
+    * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
+---*/
+
+var callCount = 0;
+
+class C { *gen() {
+    callCount += 1;
+    /*{ body }*/
+}}
+
+var gen = C.prototype.gen;
+
+var iter = gen();
+
+/*{ assertions }*/
+
+assert.sameValue(callCount, 1);
diff --git a/src/generators/default/class-decl-static-method.template b/src/generators/default/class-decl-static-method.template
new file mode 100644
index 0000000000..dcd8f4e68c
--- /dev/null
+++ b/src/generators/default/class-decl-static-method.template
@@ -0,0 +1,33 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/statements/class/gen-method-static-
+name: Static generator method as a ClassDeclaration element
+esid: prod-GeneratorMethod
+info: |
+  ClassElement :
+    static MethodDefinition
+
+  MethodDefinition :
+    GeneratorMethod
+
+  14.4 Generator Function Definitions
+
+  GeneratorMethod :
+    * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
+---*/
+
+var callCount = 0;
+
+class C {static *gen() {
+    callCount += 1;
+    /*{ body }*/
+}}
+
+var gen = C.gen;
+
+var iter = gen();
+
+/*{ assertions }*/
+
+assert.sameValue(callCount, 1);
diff --git a/src/generators/default/class-method-definition.template b/src/generators/default/class-expr-method.template
similarity index 56%
rename from src/generators/default/class-method-definition.template
rename to src/generators/default/class-expr-method.template
index 4515d51ef5..8580bb9391 100644
--- a/src/generators/default/class-method-definition.template
+++ b/src/generators/default/class-expr-method.template
@@ -2,24 +2,24 @@
 // This code is governed by the BSD license found in the LICENSE file.
 /*---
 path: language/expressions/class/gen-method-
-name: Generator method as a ClassElement
+name: Generator method as a ClassExpression element
 esid: prod-GeneratorMethod
 info: |
-  ClassElement[Yield, Await]:
-    MethodDefinition[?Yield, ?Await]
+  ClassElement :
+    MethodDefinition
 
-  MethodDefinition[Yield, Await]:
-    GeneratorMethod[?Yield, ?Await]
+  MethodDefinition :
+    GeneratorMethod
 
   14.4 Generator Function Definitions
 
-  GeneratorMethod[Yield, Await]:
-    * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
+  GeneratorMethod :
+    * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
 ---*/
 
 var callCount = 0;
 
-class C { *gen() {
+var C = class {*gen() {
     callCount += 1;
     /*{ body }*/
 }}
diff --git a/src/generators/default/class-expr-static-method.template b/src/generators/default/class-expr-static-method.template
new file mode 100644
index 0000000000..dd6e4ef0f7
--- /dev/null
+++ b/src/generators/default/class-expr-static-method.template
@@ -0,0 +1,33 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/expressions/class/gen-method-static-
+name: Static generator method as a ClassExpression element
+esid: prod-GeneratorMethod
+info: |
+  ClassElement :
+    static MethodDefinition
+
+  MethodDefinition :
+    GeneratorMethod
+
+  14.4 Generator Function Definitions
+
+  GeneratorMethod :
+    * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
+---*/
+
+var callCount = 0;
+
+var C = class { static *gen() {
+    callCount += 1;
+    /*{ body }*/
+}}
+
+var gen = C.gen;
+
+var iter = gen();
+
+/*{ assertions }*/
+
+assert.sameValue(callCount, 1);
diff --git a/src/generators/default/statement.template b/src/generators/default/declaration.template
similarity index 68%
rename from src/generators/default/statement.template
rename to src/generators/default/declaration.template
index d70481d62f..c9454f6921 100644
--- a/src/generators/default/statement.template
+++ b/src/generators/default/declaration.template
@@ -2,13 +2,13 @@
 // This code is governed by the BSD license found in the LICENSE file.
 /*---
 path: language/statements/generators/
-name: Generator function declaration
+name: Generator Function declaration
 esid: prod-GeneratorDeclaration
 info: |
   14.4 Generator Function Definitions
 
-  GeneratorDeclaration[Yield, Await, Default]:
-    function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
+  GeneratorDeclaration :
+    function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
 ---*/
 
 var callCount = 0;
diff --git a/src/generators/default/expression-named.template b/src/generators/default/expression-named.template
new file mode 100644
index 0000000000..1a2ad892d9
--- /dev/null
+++ b/src/generators/default/expression-named.template
@@ -0,0 +1,25 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/expressions/generators/named-
+name: Named generator expression
+esid: prod-GeneratorExpression
+info: |
+  14.4 Generator Function Definitions
+
+  GeneratorExpression:
+    function * BindingIdentifier opt ( FormalParameters ) { GeneratorBody }
+---*/
+
+var callCount = 0;
+
+var gen = function *g() {
+  callCount += 1;
+  /*{ body }*/
+};
+
+var iter = gen();
+
+/*{ assertions }*/
+
+assert.sameValue(callCount, 1);
diff --git a/src/generators/default/expression.template b/src/generators/default/expression.template
index ddead781f5..f66994b8b1 100644
--- a/src/generators/default/expression.template
+++ b/src/generators/default/expression.template
@@ -2,13 +2,13 @@
 // This code is governed by the BSD license found in the LICENSE file.
 /*---
 path: language/expressions/generators/
-name: Generator expression
+name: Unnamed generator expression
 esid: prod-GeneratorExpression
 info: |
   14.4 Generator Function Definitions
 
   GeneratorExpression:
-    function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
+    function * BindingIdentifier opt ( FormalParameters ) { GeneratorBody }
 ---*/
 
 var callCount = 0;
diff --git a/src/generators/default/method-definition.template b/src/generators/default/obj-method.template
similarity index 89%
rename from src/generators/default/method-definition.template
rename to src/generators/default/obj-method.template
index d075f36830..d909462bc7 100644
--- a/src/generators/default/method-definition.template
+++ b/src/generators/default/obj-method.template
@@ -1,7 +1,7 @@
 // Copyright (C) 2017 the V8 project authors. All rights reserved.
 // This code is governed by the BSD license found in the LICENSE file.
 /*---
-path: language/expressions/object/method-definition/generator-
+path: language/expressions/object/method-definition/gen-
 name: Generator method
 esid: prod-GeneratorMethod
 info: |
diff --git a/src/generators/non-strict/statement.template b/src/generators/non-strict/declaration.template
similarity index 100%
rename from src/generators/non-strict/statement.template
rename to src/generators/non-strict/declaration.template
diff --git a/src/generators/non-strict/expression-named.template b/src/generators/non-strict/expression-named.template
new file mode 100644
index 0000000000..43448e0963
--- /dev/null
+++ b/src/generators/non-strict/expression-named.template
@@ -0,0 +1,25 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/expressions/generators/named-
+name: Generator named expression - valid for non-strict only cases
+esid: prod-GeneratorExpression
+info: |
+  14.4 Generator Function Definitions
+
+  GeneratorExpression:
+    function * BindingIdentifier opt ( FormalParameters ) { GeneratorBody }
+---*/
+
+var callCount = 0;
+
+var gen = function *g() {
+  callCount += 1;
+  /*{ body }*/
+};
+
+var iter = gen();
+
+/*{ assertions }*/
+
+assert.sameValue(callCount, 1);
diff --git a/src/generators/non-strict/expression.template b/src/generators/non-strict/expression.template
index 1237f25f66..285a84b75b 100644
--- a/src/generators/non-strict/expression.template
+++ b/src/generators/non-strict/expression.template
@@ -8,7 +8,7 @@ info: |
   14.4 Generator Function Definitions
 
   GeneratorExpression:
-    function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
+    function * BindingIdentifier opt ( FormalParameters ) { GeneratorBody }
 ---*/
 
 var callCount = 0;
diff --git a/src/generators/non-strict/method-definition.template b/src/generators/non-strict/obj-method.template
similarity index 75%
rename from src/generators/non-strict/method-definition.template
rename to src/generators/non-strict/obj-method.template
index 84cee1cfd1..67b6e23377 100644
--- a/src/generators/non-strict/method-definition.template
+++ b/src/generators/non-strict/obj-method.template
@@ -1,14 +1,14 @@
 // Copyright (C) 2017 the V8 project authors. All rights reserved.
 // This code is governed by the BSD license found in the LICENSE file.
 /*---
-path: language/expressions/object/method-definition/generator-
+path: language/expressions/object/method-definition/gen-
 name: Generator method - valid for non-strict only cases
 esid: prod-GeneratorMethod
 info: |
   14.4 Generator Function Definitions
 
   GeneratorMethod[Yield, Await]:
-    * PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
+    * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
 ---*/
 
 var callCount = 0;
-- 
GitLab