-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix decorated class computed keys ordering (#16350)
* fix: memoise computed keys in decorated class * Node 6 does not support async functions * add input tests
- Loading branch information
Showing
11 changed files
with
969 additions
and
35 deletions.
There are no files selected for viewing
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
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
34 changes: 0 additions & 34 deletions
34
...ors/test/fixtures/2023-11-classes/.replacement-static-private-environment-super-2/exec.js
This file was deleted.
Oops, something went wrong.
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
118 changes: 118 additions & 0 deletions
118
.../fixtures/2023-11-ordering--to-es2015/class-decorators-without-element-decorators/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,118 @@ | ||
const classDec1 = (log) => (cls, ctxClass) => { | ||
log.push("c2"); | ||
ctxClass.addInitializer(() => log.push("c5")); | ||
ctxClass.addInitializer(() => log.push("c6")); | ||
}; | ||
const classDec2 = (log) => (cls, ctxClass) => { | ||
log.push("c1"); | ||
ctxClass.addInitializer(() => log.push("c3")); | ||
ctxClass.addInitializer(() => log.push("c4")); | ||
}; | ||
|
||
{ | ||
const log = []; | ||
|
||
@classDec1(log) | ||
@classDec2(log) | ||
class C { | ||
[log.push("k1")]; | ||
[log.push("k2")]; | ||
[log.push("k3")]; | ||
} | ||
|
||
expect(log.join()).toBe( | ||
"k1,k2,k3," + // ClassElementEvaluation | ||
"c1,c2," + // ApplyDecoratorsToClassDefinition | ||
"c3,c4,c5,c6", // classExtraInitializers | ||
); | ||
} | ||
|
||
{ | ||
const log = []; | ||
|
||
@classDec1(log) | ||
@classDec2(log) | ||
class C { | ||
static [log.push("k1")]; | ||
async [log.push("k2")](v) {}; | ||
[log.push("k3")]; | ||
} | ||
|
||
expect(log.join()).toBe( | ||
"k1,k2,k3," + // ClassElementEvaluation | ||
"c1,c2," + // ApplyDecoratorsToClassDefinition | ||
"c3,c4,c5,c6", // classExtraInitializers | ||
); | ||
} | ||
|
||
{ | ||
const log = []; | ||
|
||
@classDec1(log) | ||
@classDec2(log) | ||
class C { | ||
get [log.push("k1")]() {}; | ||
static [log.push("k2")]; | ||
[log.push("k3")]; | ||
} | ||
|
||
expect(log.join()).toBe( | ||
"k1,k2,k3," + // ClassElementEvaluation | ||
"c1,c2," + // ApplyDecoratorsToClassDefinition | ||
"c3,c4,c5,c6", // classExtraInitializers | ||
); | ||
} | ||
|
||
{ | ||
const log = []; | ||
|
||
@classDec1(log) | ||
@classDec2(log) | ||
class C { | ||
[log.push("k1")]; | ||
accessor [log.push("k2")]; | ||
static [log.push("k3")]; | ||
} | ||
|
||
expect(log.join()).toBe( | ||
"k1,k2,k3," + // ClassElementEvaluation | ||
"c1,c2," + // ApplyDecoratorsToClassDefinition | ||
"c3,c4,c5,c6", // classExtraInitializers | ||
); | ||
} | ||
|
||
{ | ||
const log = []; | ||
|
||
@classDec1(log) | ||
@classDec2(log) | ||
class C { | ||
static set [log.push("k1")](v) {}; | ||
[log.push("k2")]; | ||
static [log.push("k3")]; | ||
} | ||
|
||
expect(log.join()).toBe( | ||
"k1,k2,k3," + // ClassElementEvaluation | ||
"c1,c2," + // ApplyDecoratorsToClassDefinition | ||
"c3,c4,c5,c6", // classExtraInitializers | ||
); | ||
} | ||
|
||
{ | ||
const log = []; | ||
|
||
@classDec1(log) | ||
@classDec2(log) | ||
class C { | ||
static [log.push("k1")]; | ||
static [log.push("k2")]; | ||
static [log.push("k3")]; | ||
} | ||
|
||
expect(log.join()).toBe( | ||
"k1,k2,k3," + // ClassElementEvaluation | ||
"c1,c2," + // ApplyDecoratorsToClassDefinition | ||
"c3,c4,c5,c6", // classExtraInitializers | ||
); | ||
} |
Oops, something went wrong.