diff --git a/src/class-elements/private-field-as-arrow-function.case b/src/class-elements/private-field-as-arrow-function.case new file mode 100644 index 0000000000..9745282072 --- /dev/null +++ b/src/class-elements/private-field-as-arrow-function.case @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Calling arrow function returned from private field access +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName +template: default +features: [class-fields-private, arrow-function] +---*/ + +//- elements +#m = () => 'test262'; + +method() { + return this.#m(); +} +//- assertions +let c = new C(); +assert.sameValue(c.method(), 'test262'); diff --git a/src/class-elements/private-field-as-async-arrow-function.case b/src/class-elements/private-field-as-async-arrow-function.case new file mode 100644 index 0000000000..4791294e2e --- /dev/null +++ b/src/class-elements/private-field-as-async-arrow-function.case @@ -0,0 +1,33 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Calling async arrow function returned from private field access +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName +template: default +features: [class-fields-private, async-functions, arrow-function] +flags: [async] +---*/ + +//- elements +#m = async () => 'test262'; + +method() { + return this.#m(); +} +//- assertions +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/src/class-elements/private-field-as-async-function.case b/src/class-elements/private-field-as-async-function.case new file mode 100644 index 0000000000..0cb4760a8e --- /dev/null +++ b/src/class-elements/private-field-as-async-function.case @@ -0,0 +1,33 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Calling async function returned from private field access +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName +template: default +features: [class-fields-private, async-functions] +flags: [async] +---*/ + +//- elements +#m = async function() { return 'test262'; }; + +method() { + return this.#m(); +} +//- assertions +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/src/class-elements/private-field-as-function.case b/src/class-elements/private-field-as-function.case new file mode 100644 index 0000000000..376b7f81f1 --- /dev/null +++ b/src/class-elements/private-field-as-function.case @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Calling result returned from private field access +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName +template: default +features: [class-fields-private] +---*/ + +//- elements +#m = function () { return 'test262'; }; + +method() { + return this.#m(); +} +//- assertions +let c = new C(); +assert.sameValue(c.method(), 'test262'); diff --git a/src/class-elements/private-field-super-access-throws.case b/src/class-elements/private-field-super-access-throws.case new file mode 100644 index 0000000000..3e8ee67582 --- /dev/null +++ b/src/class-elements/private-field-super-access-throws.case @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Acessing private field from super should throw an error +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName +template: default +features: [class-fields-private, class-fields-public] +---*/ + +//- elements +#m = function() { return 'test262'; }; + +Child = class extends C { + access() { + return super.#m; + } + + method() { + return super.#m(); + } +} + +//- assertions +assert.throws(TypeError, function() { + (new (new C()).Child()).method(); +}, 'super.#m() throws TypeError'); + +assert.throws(TypeError, function() { + (new (new C()).Child()).access(); +}, 'super.#m throws TypeError'); + diff --git a/test/language/expressions/class/elements/private-field-as-arrow-function.js b/test/language/expressions/class/elements/private-field-as-arrow-function.js new file mode 100644 index 0000000000..d36b256849 --- /dev/null +++ b/test/language/expressions/class/elements/private-field-as-arrow-function.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-arrow-function.case +// - src/class-elements/default/cls-expr.template +/*--- +description: Calling arrow function returned from private field access (field definitions in a class expression) +esid: prod-FieldDefinition +features: [class-fields-private, arrow-function, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +var C = class { + #m = () => 'test262'; + + method() { + return this.#m(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'test262'); diff --git a/test/language/expressions/class/elements/private-field-as-async-arrow-function.js b/test/language/expressions/class/elements/private-field-as-async-arrow-function.js new file mode 100644 index 0000000000..c58fae344f --- /dev/null +++ b/test/language/expressions/class/elements/private-field-as-async-arrow-function.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-async-arrow-function.case +// - src/class-elements/default/cls-expr.template +/*--- +description: Calling async arrow function returned from private field access (field definitions in a class expression) +esid: prod-FieldDefinition +features: [class-fields-private, async-functions, arrow-function, class] +flags: [generated, async] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +var C = class { + #m = async () => 'test262'; + + method() { + return this.#m(); + } +} + +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/test/language/expressions/class/elements/private-field-as-async-function.js b/test/language/expressions/class/elements/private-field-as-async-function.js new file mode 100644 index 0000000000..ec0f5d0b9b --- /dev/null +++ b/test/language/expressions/class/elements/private-field-as-async-function.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-async-function.case +// - src/class-elements/default/cls-expr.template +/*--- +description: Calling async function returned from private field access (field definitions in a class expression) +esid: prod-FieldDefinition +features: [class-fields-private, async-functions, class] +flags: [generated, async] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +var C = class { + #m = async function() { return 'test262'; }; + + method() { + return this.#m(); + } +} + +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/test/language/expressions/class/elements/private-field-as-function.js b/test/language/expressions/class/elements/private-field-as-function.js new file mode 100644 index 0000000000..851c33349a --- /dev/null +++ b/test/language/expressions/class/elements/private-field-as-function.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-function.case +// - src/class-elements/default/cls-expr.template +/*--- +description: Calling result returned from private field access (field definitions in a class expression) +esid: prod-FieldDefinition +features: [class-fields-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +var C = class { + #m = function () { return 'test262'; }; + + method() { + return this.#m(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'test262'); diff --git a/test/language/expressions/class/elements/private-field-super-access-throws.js b/test/language/expressions/class/elements/private-field-super-access-throws.js new file mode 100644 index 0000000000..2759b9c9bc --- /dev/null +++ b/test/language/expressions/class/elements/private-field-super-access-throws.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-super-access-throws.case +// - src/class-elements/default/cls-expr.template +/*--- +description: Acessing private field from super should throw an error (field definitions in a class expression) +esid: prod-FieldDefinition +features: [class-fields-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +var C = class { + #m = function() { return 'test262'; }; + + Child = class extends C { + access() { + return super.#m; + } + + method() { + return super.#m(); + } + } + +} + +assert.throws(TypeError, function() { + (new (new C()).Child()).method(); +}, 'super.#m() throws TypeError'); + +assert.throws(TypeError, function() { + (new (new C()).Child()).access(); +}, 'super.#m throws TypeError'); + diff --git a/test/language/statements/class/elements/private-field-as-arrow-function.js b/test/language/statements/class/elements/private-field-as-arrow-function.js new file mode 100644 index 0000000000..c78e102bd4 --- /dev/null +++ b/test/language/statements/class/elements/private-field-as-arrow-function.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling arrow function returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, arrow-function, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = () => 'test262'; + + method() { + return this.#m(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'test262'); diff --git a/test/language/statements/class/elements/private-field-as-async-arrow-function.js b/test/language/statements/class/elements/private-field-as-async-arrow-function.js new file mode 100644 index 0000000000..69cc9b486b --- /dev/null +++ b/test/language/statements/class/elements/private-field-as-async-arrow-function.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-async-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling async arrow function returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, async-functions, arrow-function, class] +flags: [generated, async] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = async () => 'test262'; + + method() { + return this.#m(); + } +} + +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/test/language/statements/class/elements/private-field-as-async-function.js b/test/language/statements/class/elements/private-field-as-async-function.js new file mode 100644 index 0000000000..70300602f9 --- /dev/null +++ b/test/language/statements/class/elements/private-field-as-async-function.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-async-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling async function returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, async-functions, class] +flags: [generated, async] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = async function() { return 'test262'; }; + + method() { + return this.#m(); + } +} + +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/test/language/statements/class/elements/private-field-as-function.js b/test/language/statements/class/elements/private-field-as-function.js new file mode 100644 index 0000000000..30fd31a068 --- /dev/null +++ b/test/language/statements/class/elements/private-field-as-function.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling result returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = function () { return 'test262'; }; + + method() { + return this.#m(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'test262'); diff --git a/test/language/statements/class/elements/private-field-super-access-throws.js b/test/language/statements/class/elements/private-field-super-access-throws.js new file mode 100644 index 0000000000..a10d8d9f41 --- /dev/null +++ b/test/language/statements/class/elements/private-field-super-access-throws.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-super-access-throws.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Acessing private field from super should throw an error (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = function() { return 'test262'; }; + + Child = class extends C { + access() { + return super.#m; + } + + method() { + return super.#m(); + } + } + +} + +assert.throws(TypeError, function() { + (new (new C()).Child()).method(); +}, 'super.#m() throws TypeError'); + +assert.throws(TypeError, function() { + (new (new C()).Child()).access(); +}, 'super.#m throws TypeError'); +