Skip to content

Commit ec0d5a1

Browse files
committed
1 parent 0b1abd5 commit ec0d5a1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*---
2+
description: Decorator @ DecoratorCallExpression (Valid syntax for decorator on class.)
3+
esid: pending
4+
features: [class, decorators]
5+
includes: [compareArray.js]
6+
info: |
7+
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
8+
9+
---*/
10+
11+
const logs = [];
12+
const dec = (value, context) => { logs.push(context.name) };
13+
const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => (logs.push("calling toPrimitive"), "f()") }; };
14+
class Foo {
15+
@dec static accessor a;
16+
@dec static accessor #a;
17+
18+
@dec static accessor "b"
19+
@dec static accessor ["c"];
20+
21+
@dec static accessor 0;
22+
@dec static accessor [1];
23+
24+
// TODO these two throw an error with SyntaxError: Unexpected token ILLEGAL but they pass on babel's test suite. should we remove them?
25+
@dec static accessor 2n;
26+
@dec static accessor [3n];
27+
28+
@dec static accessor [f()];
29+
}
30+
31+
assert.compareArray(logs, ["computing f", "calling toPrimitive", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"], 'did it work>');

0 commit comments

Comments
 (0)