Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add accessor-initializers ordering test
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...oposal-decorators/test/fixtures/2021-12-ordering--to-es2015/accessor-initializers/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var log = []; | ||
|
||
function push(x) { log.push(x); return x; } | ||
|
||
function logClassDecoratorRun(a, b, c) { | ||
push(a); | ||
return function (el, { addInitializer }) { | ||
push(b); | ||
addInitializer(function () { push(c); }); | ||
return el; | ||
}; | ||
} | ||
|
||
function logAccessorDecoratorRun(a, b, c, d) { | ||
push(a); | ||
return function (el, { addInitializer }) { | ||
push(b); | ||
addInitializer(function () { push(c); }); | ||
return { | ||
initialize: () => push(d) | ||
}; | ||
}; | ||
} | ||
|
||
@logClassDecoratorRun(0, 19, 29) | ||
@logClassDecoratorRun(1, 18, 28) | ||
class A { | ||
@logAccessorDecoratorRun(2, 11) | ||
@logAccessorDecoratorRun(3, 10) | ||
accessor a; | ||
|
||
@logAccessorDecoratorRun(4, 13, 21, 25) | ||
@logAccessorDecoratorRun(5, 12, 20, 24) | ||
static accessor b; | ||
|
||
@logAccessorDecoratorRun(6, 15, 23, 27) | ||
@logAccessorDecoratorRun(7, 14, 22, 26) | ||
static accessor #c; | ||
|
||
@logAccessorDecoratorRun(8, 17) | ||
@logAccessorDecoratorRun(9, 16) | ||
accessor #d; | ||
} | ||
|
||
var nums = Array.from({ length: 30 }, (_, i) => i); | ||
expect(log).toEqual(nums); |