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
This commit is contained in:
Leo Balter 2018-08-20 12:15:23 -04:00
parent 331a3964d5
commit a5505bbf20
14 changed files with 249 additions and 104 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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");

View File

@ -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");