diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js')
-rw-r--r-- | js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js b/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js new file mode 100644 index 0000000000..18bd4f8a82 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-method-before-super-return-in-field-initializer.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private methods are installed "when super returns" and no earlier (call in field initializer) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + SuperCall: super Arguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceElements(result, F). + + EDITOR'S NOTE: + Private fields are added to the object one by one, interspersed with + evaluation of the initializers, following the construction of the + receiver. These semantics allow for a later initializer to refer to + a previous private field. + +---*/ + + +class C { + f = this.g(); + +} + +class D extends C { + g() { this.#m(); } + #m() { return 42; } +} + +assert(D.prototype.hasOwnProperty('g')); +assert.throws(TypeError, function() { + var d = new D(); +}, 'private methods are not installed before super returns'); + +reportCompare(0, 0); |