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, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
c.m().next().then(function(v) { c.m().next().then(function(v) {
assert.sameValue(v.value, 42); assert.sameValue(v.value, 42);
assert.sameValue(v.done, true); 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); }, $DONE).then($DONE, $DONE);

View File

@ -26,8 +26,18 @@ verifyProperty(C.prototype, "m", {
writable: true, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
c.m().then(function(v) { c.m().then(function(v) {
assert.sameValue(v, 42); 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); }, $DONE).then($DONE, $DONE);

View File

@ -26,9 +26,19 @@ verifyProperty(C, "m", {
writable: true, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
C.m().next().then(function(v) { C.m().next().then(function(v) {
assert.sameValue(v.value, 42); assert.sameValue(v.value, 42);
assert.sameValue(v.done, true); 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); }, $DONE).then($DONE, $DONE);

View File

@ -26,8 +26,18 @@ verifyProperty(C, "m", {
writable: true, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
C.m().then(function(v) { C.m().then(function(v) {
assert.sameValue(v, 42); 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); }, $DONE).then($DONE, $DONE);

View File

@ -26,9 +26,19 @@ verifyProperty(C.prototype, "m", {
writable: true, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
c.m().next().then(function(v) { c.m().next().then(function(v) {
assert.sameValue(v.value, 42); assert.sameValue(v.value, 42);
assert.sameValue(v.done, true); 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); }, $DONE).then($DONE, $DONE);

View File

@ -26,8 +26,18 @@ verifyProperty(C.prototype, "m", {
writable: true, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
c.m().then(function(v) { c.m().then(function(v) {
assert.sameValue(v, 42); 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); }, $DONE).then($DONE, $DONE);

View File

@ -26,9 +26,19 @@ verifyProperty(C, "m", {
writable: true, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
C.m().next().then(function(v) { C.m().next().then(function(v) {
assert.sameValue(v.value, 42); assert.sameValue(v.value, 42);
assert.sameValue(v.done, true); 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); }, $DONE).then($DONE, $DONE);

View File

@ -26,8 +26,18 @@ verifyProperty(C, "m", {
writable: true, writable: true,
}, {restore: true}); }, {restore: true});
/*{ assertions }*/
C.m().then(function(v) { C.m().then(function(v) {
assert.sameValue(v, 42); 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); }, $DONE).then($DONE, $DONE);

View File

@ -59,42 +59,42 @@ features: [class-static-methods-private]
---*/ ---*/
//- fields //- fields
static async #$(value) { static async * #$(value) {
yield await value; yield await value;
} }
static async #_(value) { static async * #_(value) {
yield await value; yield await value;
} }
static async #o(value) { static async * #o(value) {
yield await value; yield await value;
} }
static async #℘(value) { static async * #℘(value) {
yield await value; yield await value;
} }
static async #ZW__NJ(value) { static async * #ZW__NJ(value) {
yield await value; yield await value;
} }
static async #ZW__J(value) { static async * #ZW__J(value) {
yield await value; yield await value;
} }
//- privateinspectionfunctions //- privateinspectionfunctions
static async $(value) { static get $() {
yield * await this.#$(value); return this.#$;
} }
static async _(value) { static get _() {
yield * await this.#_(value); return this.#_;
} }
static async o(value) { static get o() {
yield * await this.#o(value); return this.#o;
} }
static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD
yield * await this.#℘(value); return this.#℘;
} }
static async ZW__NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD static get ZW__NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD
yield * await this.#ZW__NJ(value); return this.#ZW__NJ;
} }
static async ZW__J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD static get ZW__J() { // DO NOT CHANGE THE NAME OF THIS FIELD
yield * await this.#ZW__J(value); return this.#ZW__J;
} }
//- assertions //- assertions

View File

@ -60,41 +60,41 @@ features: [class-static-methods-private]
//- fields //- fields
static async * #$(value) { static async * #$(value) {
yield await value; yield * await value;
} }
static async * #_(value) { static async * #_(value) {
yield await value; yield * await value;
} }
static async * #\u{6F}(value) { static async * #\u{6F}(value) {
yield await value; yield * await value;
} }
static async * #\u2118(value) { static async * #\u2118(value) {
yield await value; yield * await value;
} }
static async * #ZW_\u200C_NJ(value) { static async * #ZW_\u200C_NJ(value) {
yield await value; yield * await value;
} }
static async * #ZW_\u200D_J(value) { static async * #ZW_\u200D_J(value) {
yield await value; yield * await value;
} }
//- privateinspectionfunctions //- privateinspectionfunctions
static async * $(value) { static async * $() {
yield * await this.#$(value); return this.#$;
} }
static async * _(value) { static async * _() {
yield * await this.#_(value); return this.#_;
} }
static async * \u{6F}(value) { static async * \u{6F}() {
yield * await this.#\u{6F}(value); return this.#\u{6F};
} }
static async * \u2118(value) { static async * \u2118() {
yield * await this.#\u2118(value); return this.#\u2118;
} }
static async * ZW_\u200C_NJ(value) { static async * ZW_\u200C_NJ() {
yield * await this.#ZW_\u200C_NJ(value); return this.#ZW_\u200C_NJ;
} }
static async * ZW_\u200D_J(value) { static async * ZW_\u200D_J() {
yield * await this.#ZW_\u200D_J(value); return this.#ZW_\u200D_J;
} }
//- assertions //- assertions

View File

@ -59,41 +59,41 @@ features: [class-static-methods-private]
//- fields //- fields
static * #$(value) { static * #$(value) {
yield value; yield * value;
} }
static * #_(value) { static * #_(value) {
yield value; yield * value;
} }
static * #o(value) { static * #o(value) {
yield value; yield * value;
} }
static * #℘(value) { static * #℘(value) {
yield value; yield * value;
} }
static * #ZW__NJ(value) { static * #ZW__NJ(value) {
yield value; yield * value;
} }
static * #ZW__J(value) { static * #ZW__J(value) {
yield value; yield * value;
} }
//- privateinspectionfunctions //- privateinspectionfunctions
static * $(value) { static get $() {
yield this.#$(value); return this.#$;
} }
static * _(value) { static get _() {
yield this.#_(value); return this.#_;
} }
static * o(value) { static get o() {
yield this.#o(value); return this.#o;
} }
static * ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD
yield this.#℘(value); return this.#℘;
} }
static * ZW__NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD static get ZW__NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD
yield this.#ZW__NJ(value); return this.#ZW__NJ;
} }
static * ZW__J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD static get ZW__J() { // DO NOT CHANGE THE NAME OF THIS FIELD
yield this.#ZW__J(value); return this.#ZW__J;
} }
//- assertions //- assertions

View File

@ -59,41 +59,41 @@ features: [class-static-methods-private]
//- fields //- fields
static * #$(value) { static * #$(value) {
yield value; yield * value;
} }
static * #_(value) { static * #_(value) {
yield value; yield * value;
} }
static * #\u{6F}(value) { static * #\u{6F}(value) {
yield value; yield * value;
} }
static * #\u2118(value) { static * #\u2118(value) {
yield value; yield * value;
} }
static * #ZW_\u200C_NJ(value) { static * #ZW_\u200C_NJ(value) {
yield value; yield * value;
} }
static * #ZW_\u200D_J(value) { static * #ZW_\u200D_J(value) {
yield value; yield * value;
} }
//- privateinspectionfunctions //- privateinspectionfunctions
static * $(value) { static get $() {
yield this.#$(value); return this.#$;
} }
static * _(value) { static get _() {
yield this.#_(value); return this.#_;
} }
static * \u{6F}(value) { static get \u{6F}() {
yield this.#\u{6F}(value); return this.#\u{6F};
} }
static * \u2118(value) { static get \u2118() {
yield this.#\u2118(value); return this.#\u2118;
} }
static * ZW_\u200C_NJ(value) { static get ZW_\u200C_NJ() {
yield this.#ZW_\u200C_NJ(value); return this.#ZW_\u200C_NJ;
} }
static * ZW_\u200D_J(value) { static get ZW_\u200D_J() {
yield this.#ZW_\u200D_J(value); return this.#ZW_\u200D_J;
} }
//- assertions //- 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] features: [class-static-methods-private]
---*/ ---*/
//- fields
static #xVal; static #yVal
//- privateinspectionfunctions //- privateinspectionfunctions
static #x(value) { static #x(value) {
this.#xVal = value; return value / 2;
return this.#xVal;
} }
static #y(value) { static #y(value) {
this.#y = value; return value * 2;
return this.#yVal;
} }
static x() { static x() {
return this.#x(42); return this.#x(84);
} }
static y() { static y() {
return this.#y(43); return this.#y(43);
@ -41,18 +37,18 @@ static y() {
//- assertions //- assertions
// Test the private methods do not appear as properties before set to value // 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.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#xVal"), false, "test 2"); assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#xVal"), false, "test 3"); 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.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#yVal"), false, "test 5"); assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#yVal"), false, "test 6"); assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value // Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7"); 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 // 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, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#yVal"), false, "test 10"); assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");