Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a test for decorator context names #4022

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions test/language/statements/class/decorator/context-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*---
description: Decorator order of operations and access to context name
esid: pending
features: [class, decorators]
includes: [compareArray.js]
info: |
This was taken from the babel test suite https://github.com/babel/babel/blob/87ec4fc3d2cf44c30ef007f7da47d7177e07ffec/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/context-name/input.js#L1

---*/

const logs = [];
const dec = (value, context) => { logs.push(context.name) };
const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => (logs.push("calling toPrimitive"), "f()") }; };
class Foo {
@dec static accessor a;
@dec static accessor #a;

@dec static accessor "b"
@dec static accessor ["c"];

@dec static accessor 0;
@dec static accessor [1];

@dec static accessor 2n;
@dec static accessor [3n];

@dec static accessor [f()];
}

assert.compareArray(logs, ["computing f", "calling toPrimitive", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"], 'order of observable operations in evaluating class definition');
Loading