-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a test for decorator context names #4022
base: main
Are you sure you want to change the base?
Conversation
// TODO these two throw an error with SyntaxError: Unexpected token ILLEGAL but they pass on babel's test suite. should we remove them? | ||
@dec static accessor 2n; | ||
@dec static accessor [3n]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are currently failing when I use the babel-test262-runner to test them but are working upstream in babel so I don't know if I should keep these two cases 🤔 thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I looked at these and they seem correct according to the current text of the decorators proposal. I don't really have a good sense of whether we already have coverage for this stuff so it'd be helpful if we could get a look from someone who's been involved with decorator tests before.
About the bigint property names, the question is, are they correct according to the spec. As far as I can tell, they are.
Here's the relevant grammar, with [Yield, Await] elided:
- ClassElement : DecoratorListopt
static
FieldDefinition;
- FieldDefinition :
accessor
[no LineTerminator here] ClassElementName Initializeropt - ClassElementName : PropertyName
- PropertyName : LiteralPropertyName
- LiteralPropertyName : NumericLiteral
- NumericLiteral : DecimalBigIntegerLiteral
(similar for PropertyName : ComputedPropertyName but with a longer path through all of the expression precedence elements)
So I don't think the SyntaxError is correct there.
ec0d5a1
to
d303820
Compare
Thanks for the review @ptomato 🎉 I've updated the message and removed my TODO item for removing the seemingly valid syntax 👍 is there something that I need to do to the frontmatter to mark it that it's currently expected to fail?
So I have 2 thoughts on this. If adding this test has identified a legitimate error that should have passed then this is clearly adding coverage for something that wasn't already covered 😂 But looking at the files that are already in the suite for decorators it seems that there are only But anyway, I'm adding these tests with the help of @pzuraq so I'm sure she'll be the best person to comment on this 😂 |
Decorators coverage right now is something like 0.1%, so thank you very much! If you plan to submit more tests, it would be incredibly useful if you could write a "testing plan" (like #3725) so that it's easier to tell what's covered and what's not. |
Please add a copyright header as well |
@mansona There are no expected-to-fail tests, so nothing to do on your end. (The way it works is, a hypothetical JS implementation that correctly implements the spec plus all stage-3 proposals must pass all test262 tests. Implementations maintain their own expected-to-fail lists separately.) |
So I was wondering about that one 🤔 As I said in the description I copied the test from the babel test suite, so should I set the copyright header to the original author? Is there any guidance on that? |
Copyrights are annoying to deal with, sorry. Ideally the Babel test file would have its own copyright header, but it doesn't. You'd have to ask the Babel project if the copyright line in babel/LICENSE ("Copyright (c) 2014-present Sebastian McKenzie and other contributors") applies to everything in the babel repo. If not, then you'd have to talk to the authors of that file figure out who owns the copyright. (Public service announcement: Open source projects, please require license and copyright headers in every file in the repo! There are tools such as REUSE that you can drop into your CI and make this easy, or you can roll your own like test262 does 😄) |
Hey, could you use "The Babel Team"? Unfortunately different packages in our repo have different author/copyright owner, so the best thing to do is to look for the author field in the relevant package.json (https://github.com/babel/babel/blob/dd699a8509f02efd7e5a45d49cf24b757a59e4a2/packages/babel-plugin-proposal-decorators/package.json#L4C14-L4C30) |
@nicolo-ribaudo I've made a test plan in this issue: #4042 |
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