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 86112b8c1b132582339e0041a1260781828d9a75..f7eb3bd09ee001b53dd3e997e39df4e4c9714520 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 0c2e40f9c6d9f342683f10af9b8570acbec04593..f0235f2968cc102e42af64b0d8bc4484a214331c 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 5f2527b23139c9c2b154af4cec791781234b032a..1f20b30cadbe89159d4ebbb5f8a1668403affe75 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 78d5c7ad6fc37aa496111e65fd70674426ab8790..15e777602472ed715dbb9abf0a8e9f69efd8410d 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 ce74f1e48859f6202455cd714754ad3432ab1d2a..9fbf8d3abbdced212a505538fb1aa7c58dc3e062 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 5159fb2431c38516949943c72ac9d553a5cde822..8b7a65b8841ec0ca8e71c8b78886c706963f8693 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 0a1cb278694a6f8602ceb814111a042ec15d9f56..f17089165747ec4e9a3b2fafe0c6bb412514a4ef 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 ff00a66a60c9e70cc4b9287ce219565c72c260c8..2cf8679f24381c8a2d6997841e9a8aa17ec553e6 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 1b5473a9ab272bb4bc22b0e8e376c5f9dd6b7c9d..d43fe887e2b94e37be1ff2b759f53c7fe356d811 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 f29b16414e3a92c4eba6a405e321ee6c584c17d0..7f299d507468f925a878fe86b1926f0a0f753b3b 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 500426daba6a17003f0c5a37471a338888683a96..9fe46136af7a2f769371f97da75789e4c6cea676 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 0b7dd4558f11b8dd80b6a57e4fe3a9fe8fb30e20..a263c826847e571e3a3b7423360954de65fdb8f7 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 0000000000000000000000000000000000000000..6334a58c7decaec411e7e798b301ab9cf02abc25 --- /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 50b6565f24e8b5fb931165db038b276dbd35c63b..9d86d6ac6978a655f8db778f9916ac23800738a2 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");