From f81c2f5422e2f764e1a8454dea2779e7196f08ec Mon Sep 17 00:00:00 2001 From: Caio Lima Date: Wed, 13 Jan 2021 09:31:23 -0300 Subject: [PATCH] Adding test case for super access from class field defined as arrow function --- ...super-access-from-arrow-func-on-field.case | 35 ++++++++++++++++++ .../super-access-from-arrow-func-on-field.js | 37 +++++++++++++++++++ .../super-access-from-arrow-func-on-field.js | 37 +++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 src/class-elements/super-access-from-arrow-func-on-field.case create mode 100644 test/language/expressions/class/elements/super-access-from-arrow-func-on-field.js create mode 100644 test/language/statements/class/elements/super-access-from-arrow-func-on-field.js diff --git a/src/class-elements/super-access-from-arrow-func-on-field.case b/src/class-elements/super-access-from-arrow-func-on-field.case new file mode 100644 index 0000000000..f40e35f338 --- /dev/null +++ b/src/class-elements/super-access-from-arrow-func-on-field.case @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: super inside arrow functions on field initializer resolves to class' super +info: | + ClassElementName : + PropertyName + PrivateName + + SuperProperty: + super[Expression] + super.IdentifierName + +template: default +features: [class-fields-public, class-static-fields-public] +---*/ + +//- elements +func = () => { + super.prop = 'test262'; +} + +static staticFunc = () => { + super.staticProp = 'static test262'; +} +//- assertions + +let c = new C(); +c.func(); +assert.sameValue(c.prop, 'test262'); + +C.staticFunc(); +assert.sameValue(C.staticProp, 'static test262'); + diff --git a/test/language/expressions/class/elements/super-access-from-arrow-func-on-field.js b/test/language/expressions/class/elements/super-access-from-arrow-func-on-field.js new file mode 100644 index 0000000000..6dc39324df --- /dev/null +++ b/test/language/expressions/class/elements/super-access-from-arrow-func-on-field.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/super-access-from-arrow-func-on-field.case +// - src/class-elements/default/cls-expr.template +/*--- +description: super inside arrow functions on field initializer resolves to class' super (field definitions in a class expression) +esid: prod-FieldDefinition +features: [class-fields-public, class-static-fields-public, class] +flags: [generated] +info: | + ClassElementName : + PropertyName + PrivateName + + SuperProperty: + super[Expression] + super.IdentifierName + +---*/ + + +var C = class { + func = () => { + super.prop = 'test262'; + } + + static staticFunc = () => { + super.staticProp = 'static test262'; + } +} + +let c = new C(); +c.func(); +assert.sameValue(c.prop, 'test262'); + +C.staticFunc(); +assert.sameValue(C.staticProp, 'static test262'); + diff --git a/test/language/statements/class/elements/super-access-from-arrow-func-on-field.js b/test/language/statements/class/elements/super-access-from-arrow-func-on-field.js new file mode 100644 index 0000000000..8a57742273 --- /dev/null +++ b/test/language/statements/class/elements/super-access-from-arrow-func-on-field.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/super-access-from-arrow-func-on-field.case +// - src/class-elements/default/cls-decl.template +/*--- +description: super inside arrow functions on field initializer resolves to class' super (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class-static-fields-public, class] +flags: [generated] +info: | + ClassElementName : + PropertyName + PrivateName + + SuperProperty: + super[Expression] + super.IdentifierName + +---*/ + + +class C { + func = () => { + super.prop = 'test262'; + } + + static staticFunc = () => { + super.staticProp = 'static test262'; + } +} + +let c = new C(); +c.func(); +assert.sameValue(c.prop, 'test262'); + +C.staticFunc(); +assert.sameValue(C.staticProp, 'static test262'); +