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 0000000000000000000000000000000000000000..d36b25684978c05896ba8e59dd6f575c68e4de1f --- /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 0000000000000000000000000000000000000000..3033aec4c54a2d3cca1bb9961579eb86356d3b6e --- /dev/null +++ b/test/language/expressions/class/elements/private-field-as-async-arrow-function.js @@ -0,0 +1,39 @@ +// 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] +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(); + +async function asyncRun() { + assert.sameValue(await c.method(), 'test262'); +} + +asyncRun(); + 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 0000000000000000000000000000000000000000..6aea0dc10c3e49b26af955c7e6dde19eca686279 --- /dev/null +++ b/test/language/expressions/class/elements/private-field-as-async-function.js @@ -0,0 +1,39 @@ +// 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] +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(); + +async function asyncRun() { + assert.sameValue(await c.method(), 'test262'); +} + +asyncRun(); + 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 0000000000000000000000000000000000000000..851c33349a74d4e70a708c40449f508e3d2baa51 --- /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 0000000000000000000000000000000000000000..fc566d93d5cebce7da249b7d9bdeba46a0a65e91 --- /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 shoudl 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 0000000000000000000000000000000000000000..c78e102bd462f368763e018700838255973dc688 --- /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 0000000000000000000000000000000000000000..665b50817a49cf0cd9d14cd66b56ee4b33b8e297 --- /dev/null +++ b/test/language/statements/class/elements/private-field-as-async-arrow-function.js @@ -0,0 +1,39 @@ +// 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] +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(); + +async function asyncRun() { + assert.sameValue(await c.method(), 'test262'); +} + +asyncRun(); + 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 0000000000000000000000000000000000000000..2ef5910b3c90030ffb3e9597c967b3ef80c63eab --- /dev/null +++ b/test/language/statements/class/elements/private-field-as-async-function.js @@ -0,0 +1,39 @@ +// 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] +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(); + +async function asyncRun() { + assert.sameValue(await c.method(), 'test262'); +} + +asyncRun(); + 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 0000000000000000000000000000000000000000..30fd31a068f3e882854dc2c9be08fc4f29b89d07 --- /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 0000000000000000000000000000000000000000..62029afd53c760e6fc21be48af26511a08e46130 --- /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 shoudl 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'); +