test262/test/language/statements/class/elements/private-field-super-access-throws.js
2019-02-06 18:18:48 -02:00

47 lines
1.2 KiB
JavaScript

// 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');