From a5505bbf2001669167742ea870f8d1409f7b30e7 Mon Sep 17 00:00:00 2001
From: Leo Balter <leonardo.balter@gmail.com>
Date: Mon, 20 Aug 2018 12:15:23 -0400
Subject: [PATCH] Address feedback from PR review

- needs to use async* to declare async generator methods.
- Needs to use yield* if delegating yield semantics are intended.
- Has assignment to private name method, which is not allowed and throws a TypeError at runtime.
- handle multiple $DONE calls
- fix calls to private methods
---
 ...ls-decl-after-same-line-async-gen.template | 14 +++-
 ...decl-after-same-line-async-method.template | 14 +++-
 ...-after-same-line-static-async-gen.template | 14 +++-
 ...ter-same-line-static-async-method.template | 14 +++-
 ...ls-expr-after-same-line-async-gen.template | 14 +++-
 ...expr-after-same-line-async-method.template | 14 +++-
 ...-after-same-line-static-async-gen.template | 14 +++-
 ...ter-same-line-static-async-method.template | 14 +++-
 ...tor-method-privatename-identifier-alt.case | 36 +++++-----
 ...nerator-method-privatename-identifier.case | 36 +++++-----
 ...tor-method-privatename-identifier-alt.case | 36 +++++-----
 ...nerator-method-privatename-identifier.case | 36 +++++-----
 .../static-private-methods-with-fields.case   | 69 +++++++++++++++++++
 src/class-fields/static-private-methods.case  | 28 ++++----
 14 files changed, 249 insertions(+), 104 deletions(-)
 create mode 100644 src/class-fields/static-private-methods-with-fields.case

diff --git a/src/class-fields/productions/cls-decl-after-same-line-async-gen.template b/src/class-fields/productions/cls-decl-after-same-line-async-gen.template
index 86112b8c1b..f7eb3bd09e 100644
--- a/src/class-fields/productions/cls-decl-after-same-line-async-gen.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-async-gen.template
@@ -26,9 +26,19 @@ verifyProperty(C.prototype, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 c.m().next().then(function(v) {
   assert.sameValue(v.value, 42);
   assert.sameValue(v.done, true);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/productions/cls-decl-after-same-line-async-method.template b/src/class-fields/productions/cls-decl-after-same-line-async-method.template
index 0c2e40f9c6..f0235f2968 100644
--- a/src/class-fields/productions/cls-decl-after-same-line-async-method.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-async-method.template
@@ -26,8 +26,18 @@ verifyProperty(C.prototype, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 c.m().then(function(v) {
   assert.sameValue(v, 42);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/productions/cls-decl-after-same-line-static-async-gen.template b/src/class-fields/productions/cls-decl-after-same-line-static-async-gen.template
index 5f2527b231..1f20b30cad 100644
--- a/src/class-fields/productions/cls-decl-after-same-line-static-async-gen.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-static-async-gen.template
@@ -26,9 +26,19 @@ verifyProperty(C, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 C.m().next().then(function(v) {
   assert.sameValue(v.value, 42);
   assert.sameValue(v.done, true);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/productions/cls-decl-after-same-line-static-async-method.template b/src/class-fields/productions/cls-decl-after-same-line-static-async-method.template
index 78d5c7ad6f..15e7776024 100644
--- a/src/class-fields/productions/cls-decl-after-same-line-static-async-method.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-static-async-method.template
@@ -26,8 +26,18 @@ verifyProperty(C, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 C.m().then(function(v) {
   assert.sameValue(v, 42);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/productions/cls-expr-after-same-line-async-gen.template b/src/class-fields/productions/cls-expr-after-same-line-async-gen.template
index ce74f1e488..9fbf8d3abb 100644
--- a/src/class-fields/productions/cls-expr-after-same-line-async-gen.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-async-gen.template
@@ -26,9 +26,19 @@ verifyProperty(C.prototype, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 c.m().next().then(function(v) {
   assert.sameValue(v.value, 42);
   assert.sameValue(v.done, true);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/productions/cls-expr-after-same-line-async-method.template b/src/class-fields/productions/cls-expr-after-same-line-async-method.template
index 5159fb2431..8b7a65b884 100644
--- a/src/class-fields/productions/cls-expr-after-same-line-async-method.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-async-method.template
@@ -26,8 +26,18 @@ verifyProperty(C.prototype, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 c.m().then(function(v) {
   assert.sameValue(v, 42);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/productions/cls-expr-after-same-line-static-async-gen.template b/src/class-fields/productions/cls-expr-after-same-line-static-async-gen.template
index 0a1cb27869..f170891657 100644
--- a/src/class-fields/productions/cls-expr-after-same-line-static-async-gen.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-static-async-gen.template
@@ -26,9 +26,19 @@ verifyProperty(C, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 C.m().next().then(function(v) {
   assert.sameValue(v.value, 42);
   assert.sameValue(v.done, true);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/productions/cls-expr-after-same-line-static-async-method.template b/src/class-fields/productions/cls-expr-after-same-line-static-async-method.template
index ff00a66a60..2cf8679f24 100644
--- a/src/class-fields/productions/cls-expr-after-same-line-static-async-method.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-static-async-method.template
@@ -26,8 +26,18 @@ verifyProperty(C, "m", {
   writable: true,
 }, {restore: true});
 
-/*{ assertions }*/
-
 C.m().then(function(v) {
   assert.sameValue(v, 42);
+
+  function assertions() {
+    // Cover $DONE handler for async cases.
+    function $DONE(error) {
+      if (error) {
+        throw new Test262Error('Test262:AsyncTestFailure')
+      }
+    }
+    /*{ assertions }*/
+  }
+
+  return Promise.resolve(assertions());
 }, $DONE).then($DONE, $DONE);
diff --git a/src/class-fields/rs-static-async-generator-method-privatename-identifier-alt.case b/src/class-fields/rs-static-async-generator-method-privatename-identifier-alt.case
index 1b5473a9ab..d43fe887e2 100644
--- a/src/class-fields/rs-static-async-generator-method-privatename-identifier-alt.case
+++ b/src/class-fields/rs-static-async-generator-method-privatename-identifier-alt.case
@@ -59,42 +59,42 @@ features: [class-static-methods-private]
 ---*/
 
 //- fields
-static async #$(value) {
+static async * #$(value) {
   yield await value;
 }
-static async #_(value) {
+static async * #_(value) {
   yield await value;
 }
-static async #o(value) {
+static async * #o(value) {
   yield await value;
 }
-static async #℘(value) {
+static async * #℘(value) {
   yield await value;
 }
-static async #ZW_‌_NJ(value) {
+static async * #ZW_‌_NJ(value) {
   yield await value;
 }
-static async #ZW_‍_J(value) {
+static async * #ZW_‍_J(value) {
   yield await value;
 }
 //- privateinspectionfunctions
-static async $(value) {
-  yield * await this.#$(value);
+static get $() {
+ return this.#$;
 }
-static async _(value) {
-  yield * await this.#_(value);
+static get _() {
+ return this.#_;
 }
-static async o(value) {
-  yield * await this.#o(value);
+static get o() {
+ return this.#o;
 }
-static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD
-  yield * await this.#℘(value);
+static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD
+ return this.#℘;
 }
-static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD
-  yield * await this.#ZW_‌_NJ(value);
+static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD
+ return this.#ZW_‌_NJ;
 }
-static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD
-  yield * await this.#ZW_‍_J(value);
+static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD
+ return this.#ZW_‍_J;
 }
 
 //- assertions
diff --git a/src/class-fields/rs-static-async-generator-method-privatename-identifier.case b/src/class-fields/rs-static-async-generator-method-privatename-identifier.case
index f29b16414e..7f299d5074 100644
--- a/src/class-fields/rs-static-async-generator-method-privatename-identifier.case
+++ b/src/class-fields/rs-static-async-generator-method-privatename-identifier.case
@@ -60,41 +60,41 @@ features: [class-static-methods-private]
 
 //- fields
 static async * #$(value) {
-  yield await value;
+  yield * await value;
 }
 static async * #_(value) {
-  yield await value;
+  yield * await value;
 }
 static async * #\u{6F}(value) {
-  yield await value;
+  yield * await value;
 }
 static async * #\u2118(value) {
-  yield await value;
+  yield * await value;
 }
 static async * #ZW_\u200C_NJ(value) {
-  yield await value;
+  yield * await value;
 }
 static async * #ZW_\u200D_J(value) {
-  yield await value;
+  yield * await value;
 }
 //- privateinspectionfunctions
-static async * $(value) {
-  yield * await this.#$(value);
+static async * $() {
+  return this.#$;
 }
-static async * _(value) {
-  yield * await this.#_(value);
+static async * _() {
+  return this.#_;
 }
-static async * \u{6F}(value) {
-  yield * await this.#\u{6F}(value);
+static async * \u{6F}() {
+  return this.#\u{6F};
 }
-static async * \u2118(value) {
-  yield * await this.#\u2118(value);
+static async * \u2118() {
+  return this.#\u2118;
 }
-static async * ZW_\u200C_NJ(value) {
-  yield * await this.#ZW_\u200C_NJ(value);
+static async * ZW_\u200C_NJ() {
+  return this.#ZW_\u200C_NJ;
 }
-static async * ZW_\u200D_J(value) {
-  yield * await this.#ZW_\u200D_J(value);
+static async * ZW_\u200D_J() {
+  return this.#ZW_\u200D_J;
 }
 
 //- assertions
diff --git a/src/class-fields/rs-static-generator-method-privatename-identifier-alt.case b/src/class-fields/rs-static-generator-method-privatename-identifier-alt.case
index 500426daba..9fe46136af 100644
--- a/src/class-fields/rs-static-generator-method-privatename-identifier-alt.case
+++ b/src/class-fields/rs-static-generator-method-privatename-identifier-alt.case
@@ -59,41 +59,41 @@ features: [class-static-methods-private]
 
 //- fields
 static * #$(value) {
-  yield value;
+  yield * value;
 }
 static * #_(value) {
-  yield value;
+  yield * value;
 }
 static * #o(value) {
-  yield value;
+  yield * value;
 }
 static * #℘(value) {
-  yield value;
+  yield * value;
 }
 static * #ZW_‌_NJ(value) {
-  yield value;
+  yield * value;
 }
 static * #ZW_‍_J(value) {
-  yield value;
+  yield * value;
 }
 //- privateinspectionfunctions
-static * $(value) {
-  yield this.#$(value);
+static get $() {
+  return this.#$;
 }
-static * _(value) {
-  yield this.#_(value);
+static get _() {
+  return this.#_;
 }
-static * o(value) {
-  yield this.#o(value);
+static get o() {
+  return this.#o;
 }
-static * ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD
-  yield this.#℘(value);
+static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD
+  return this.#℘;
 }
-static * ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD
-  yield this.#ZW_‌_NJ(value);
+static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD
+  return this.#ZW_‌_NJ;
 }
-static * ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD
-  yield this.#ZW_‍_J(value);
+static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD
+  return this.#ZW_‍_J;
 }
 
 //- assertions
diff --git a/src/class-fields/rs-static-generator-method-privatename-identifier.case b/src/class-fields/rs-static-generator-method-privatename-identifier.case
index 0b7dd4558f..a263c82684 100644
--- a/src/class-fields/rs-static-generator-method-privatename-identifier.case
+++ b/src/class-fields/rs-static-generator-method-privatename-identifier.case
@@ -59,41 +59,41 @@ features: [class-static-methods-private]
 
 //- fields
 static * #$(value) {
-  yield value;
+  yield * value;
 }
 static * #_(value) {
-  yield value;
+  yield * value;
 }
 static * #\u{6F}(value) {
-  yield value;
+  yield * value;
 }
 static * #\u2118(value) {
-  yield value;
+  yield * value;
 }
 static * #ZW_\u200C_NJ(value) {
-  yield value;
+  yield * value;
 }
 static * #ZW_\u200D_J(value) {
-  yield value;
+  yield * value;
 }
 //- privateinspectionfunctions
-static * $(value) {
-  yield this.#$(value);
+static get $() {
+  return this.#$;
 }
-static * _(value) {
-  yield this.#_(value);
+static get _() {
+  return this.#_;
 }
-static * \u{6F}(value) {
-  yield this.#\u{6F}(value);
+static get \u{6F}() {
+  return this.#\u{6F};
 }
-static * \u2118(value) {
-  yield this.#\u2118(value);
+static get \u2118() {
+  return this.#\u2118;
 }
-static * ZW_\u200C_NJ(value) {
-  yield this.#ZW_\u200C_NJ(value);
+static get ZW_\u200C_NJ() {
+  return this.#ZW_\u200C_NJ;
 }
-static * ZW_\u200D_J(value) {
-  yield this.#ZW_\u200D_J(value);
+static get ZW_\u200D_J() {
+  return this.#ZW_\u200D_J;
 }
 
 //- assertions
diff --git a/src/class-fields/static-private-methods-with-fields.case b/src/class-fields/static-private-methods-with-fields.case
new file mode 100644
index 0000000000..6334a58c7d
--- /dev/null
+++ b/src/class-fields/static-private-methods-with-fields.case
@@ -0,0 +1,69 @@
+// Copyright (C) 2017 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: static private methods with fields
+info: |
+  ClassElement :
+    ...
+    static FieldDefinition ;
+
+  FieldDefinition :
+    ClassElementName Initializer_opt
+
+  ClassElementName :
+    PrivateName
+
+  PrivateName :
+    # IdentifierName
+
+template: productions
+features: [class-static-methods-private, class-static-fields-private]
+---*/
+
+//- fields
+static #xVal; static #yVal
+//- privateinspectionfunctions
+static #x(value) {
+  this.#xVal = value;
+  return this.#xVal;
+}
+static #y(value) {
+  this.#yVal = value;
+  return this.#yVal;
+}
+static x() {
+  return this.#x(42);
+}
+static y() {
+  return this.#y(43);
+}
+//- assertions
+
+// Test the private methods do not appear as properties before set to value
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
+assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
+assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
+assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
+assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#xVal"), false, "test 7");
+assert.sameValue(Object.hasOwnProperty.call(C, "#xVal"), false, "test 8");
+assert.sameValue(Object.hasOwnProperty.call(c, "#xVal"), false, "test 9");
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#yVal"), false, "test 10");
+assert.sameValue(Object.hasOwnProperty.call(C, "#yVal"), false, "test 11");
+assert.sameValue(Object.hasOwnProperty.call(c, "#yVal"), false, "test 12");
+
+// Test if private fields can be sucessfully accessed and set to value
+assert.sameValue(C.x(), 42, "test 13");
+assert.sameValue(C.y(), 43, "test 14");
+
+// Test the private fields do not appear as properties before after set to value
+assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 15");
+assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 16");
+
+assert.sameValue(Object.hasOwnProperty.call(C, "#xVal"), false, "test 17");
+assert.sameValue(Object.hasOwnProperty.call(C, "#yVal"), false, "test 18");
diff --git a/src/class-fields/static-private-methods.case b/src/class-fields/static-private-methods.case
index 50b6565f24..9d86d6ac69 100644
--- a/src/class-fields/static-private-methods.case
+++ b/src/class-fields/static-private-methods.case
@@ -21,19 +21,15 @@ template: productions
 features: [class-static-methods-private]
 ---*/
 
-//- fields
-static #xVal; static #yVal
 //- privateinspectionfunctions
 static #x(value) {
-  this.#xVal = value;
-  return this.#xVal;
+  return value / 2;
 }
 static #y(value) {
-  this.#y = value;
-  return this.#yVal;
+  return value * 2;
 }
 static x() {
-  return this.#x(42);
+  return this.#x(84);
 }
 static y() {
   return this.#y(43);
@@ -41,18 +37,18 @@ static y() {
 //- assertions
 
 // Test the private methods do not appear as properties before set to value
-assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#xVal"), false, "test 1");
-assert.sameValue(Object.hasOwnProperty.call(C, "#xVal"), false, "test 2");
-assert.sameValue(Object.hasOwnProperty.call(c, "#xVal"), false, "test 3");
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
+assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
+assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
 
-assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#yVal"), false, "test 4");
-assert.sameValue(Object.hasOwnProperty.call(C, "#yVal"), false, "test 5");
-assert.sameValue(Object.hasOwnProperty.call(c, "#yVal"), false, "test 6");
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
+assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
+assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
 
 // Test if private fields can be sucessfully accessed and set to value
 assert.sameValue(C.x(), 42, "test 7");
-assert.sameValue(C.y(), 43, "test 8");
+assert.sameValue(C.y(), 86, "test 8");
 
 // Test the private fields do not appear as properties before after set to value
-assert.sameValue(Object.hasOwnProperty.call(C, "#xVal"), false, "test 9");
-assert.sameValue(Object.hasOwnProperty.call(C, "#yVal"), false, "test 10");
+assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
+assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");
-- 
GitLab