Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure decorators are callable (#16388)
- Loading branch information
Showing
5 changed files
with
97 additions
and
11 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
43 changes: 43 additions & 0 deletions
43
...-decorators/test/fixtures/2023-11-misc--to-es2015/invalid-non-callable-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,43 @@ | ||
{ | ||
"invalid non-callable class decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => @nonCallable class {}).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid non-callable field decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => class { @nonCallable field }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid non-callable accessor decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => class { @nonCallable accessor accessor; }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid non-callable method decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => class { @nonCallable method() {} }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined class decorators"; | ||
expect(() => @(void 0) class {}).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined field decorators"; | ||
expect(() => class { @(void 0) field }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined accessor decorators"; | ||
expect(() => class { @(void 0) accessor accessor; }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined method decorators"; | ||
expect(() => class { @(void 0) method() {} }).toThrow("A decorator must be a function"); | ||
} |
43 changes: 43 additions & 0 deletions
43
...in-proposal-decorators/test/fixtures/2023-11-misc/invalid-non-callable-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,43 @@ | ||
{ | ||
"invalid non-callable class decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => @nonCallable class {}).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid non-callable field decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => class { @nonCallable field }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid non-callable accessor decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => class { @nonCallable accessor accessor; }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid non-callable method decorators"; | ||
const nonCallable = { call() {}, bind() {}, apply() {} } | ||
expect(() => class { @nonCallable method() {} }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined class decorators"; | ||
expect(() => @(void 0) class {}).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined field decorators"; | ||
expect(() => class { @(void 0) field }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined accessor decorators"; | ||
expect(() => class { @(void 0) accessor accessor; }).toThrow("A decorator must be a function"); | ||
} | ||
|
||
{ | ||
"invalid undefined method decorators"; | ||
expect(() => class { @(void 0) method() {} }).toThrow("A decorator must be a function"); | ||
} |
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