From 9fe84c576ab1be55c17c23a08cf7003eaf026752 Mon Sep 17 00:00:00 2001 From: Caio Lima Date: Wed, 6 Feb 2019 17:13:42 -0200 Subject: [PATCH] Added missing cases of private field as function --- .../private-field-as-arrow-function.case | 31 ++++++++++++++ ...private-field-as-async-arrow-function.case | 37 ++++++++++++++++ .../private-field-as-async-function.case | 37 ++++++++++++++++ .../private-field-as-function.case | 31 ++++++++++++++ .../private-field-super-access-throws.case | 42 +++++++++++++++++++ 5 files changed, 178 insertions(+) create mode 100644 src/class-elements/private-field-as-arrow-function.case create mode 100644 src/class-elements/private-field-as-async-arrow-function.case create mode 100644 src/class-elements/private-field-as-async-function.case create mode 100644 src/class-elements/private-field-as-function.case create mode 100644 src/class-elements/private-field-super-access-throws.case 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..5d74655e68 --- /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 0000000000..47460425f8 --- /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 0000000000..ea67edb6cf --- /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 0000000000..7c85fa6c55 --- /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 0000000000..2ca109d8a4 --- /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'); +