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 0000000000000000000000000000000000000000..5d74655e683aab40bc0e310e6d8c6061f426713e --- /dev/null +++ b/src/class-elements/private-field-as-arrow-function.case @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved. +// Copyright (C) 2018 Leo Balter. 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 0000000000000000000000000000000000000000..47460425f80741e6ef47a35a6e788dc83dcca8ff --- /dev/null +++ b/src/class-elements/private-field-as-async-arrow-function.case @@ -0,0 +1,37 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved. +// Copyright (C) 2018 Leo Balter. 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] +---*/ + +//- elements +#m = async () => 'test262'; + +method() { + return this.#m(); +} +//- assertions +let c = new C(); + +async function asyncRun() { + assert.sameValue(await c.method(), 'test262'); +} + +asyncRun(); + 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 0000000000000000000000000000000000000000..ea67edb6cff30fab58567fa3c64f07de117d8892 --- /dev/null +++ b/src/class-elements/private-field-as-async-function.case @@ -0,0 +1,37 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved. +// Copyright (C) 2018 Leo Balter. 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] +---*/ + +//- elements +#m = async function() { return 'test262'; }; + +method() { + return this.#m(); +} +//- assertions +let c = new C(); + +async function asyncRun() { + assert.sameValue(await c.method(), 'test262'); +} + +asyncRun(); + 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 0000000000000000000000000000000000000000..7c85fa6c559d74732a86dc9d5747ba05d0870d0b --- /dev/null +++ b/src/class-elements/private-field-as-function.case @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved. +// Copyright (C) 2018 Leo Balter. 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 0000000000000000000000000000000000000000..2ca109d8a490ad9bb15d792d4004086e8da1b100 --- /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 shoudl 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'); +