| 1 |
function dec(_v, context) { |
| 2 |
return function (v) { |
| 3 |
this[context.name + 'Context'] = context; |
| 4 |
return (v || 1) + 1; |
| 5 |
} |
| 6 |
} |
| 7 |
|
| 8 |
class Foo { |
| 9 |
@dec |
| 10 |
static #a; |
| 11 |
|
| 12 |
@dec |
| 13 |
static #b = 123; |
| 14 |
} |
| 15 |
|
| 16 |
const aContext = Foo['#aContext']; |
| 17 |
const bContext = Foo['#bContext']; |
| 18 |
|
| 19 |
expect(aContext.access.get.call(Foo)).toBe(2); |
| 20 |
aContext.access.set.call(Foo, 123); |
| 21 |
expect(aContext.access.get.call(Foo)).toBe(123); |
| 22 |
expect(aContext.name).toBe('#a'); |
| 23 |
expect(aContext.kind).toBe('field'); |
| 24 |
expect(aContext.static).toBe(true); |
| 25 |
expect(aContext.private).toBe(true); |
| 26 |
expect(typeof aContext.addInitializer).toBe('undefined'); |
| 27 |
|
| 28 |
expect(bContext.access.get.call(Foo)).toBe(124); |
| 29 |
bContext.access.set.call(Foo, 123); |
| 30 |
expect(bContext.access.get.call(Foo)).toBe(123); |
| 31 |
expect(bContext.name).toBe('#b'); |
| 32 |
expect(bContext.kind).toBe('field'); |
| 33 |
expect(bContext.static).toBe(true); |
| 34 |
expect(bContext.private).toBe(true); |
| 35 |
expect(typeof aContext.addInitializer).toBe('undefined'); |