test262 icon indicating copy to clipboard operation
test262 copied to clipboard

Add decorators tests

Open pzuraq opened this issue 1 year ago • 9 comments

This PR is still a WIP, I will be trying to wrap it up tomorrow. Took me a while to get best way to combine templates and cases to have as wide coverage as possible without having to write out every permutation manually.

pzuraq avatar May 30 '24 23:05 pzuraq

I've completed writing the tests, now I just need to actually get them to run properly and debug any issues (could be typos, etc).

pzuraq avatar Jun 02 '24 16:06 pzuraq

https://github.com/babel/babel-test262-runner/ could be useful to run the tests and check if they have any problem.

nicolo-ribaudo avatar Jun 02 '24 16:06 nicolo-ribaudo

Yes, I've been using that repo for testing in general. The previous commit for fields (a3b4282) was passing, at that point I kinda had all the details figured out for the overall structure so I scaffolded out all of the tests themselves and made sure I had written all of the ones we needed.

Next is just running them again to see if they work and fixing issues. I'm sure there are minor issues, definitely, but could also be some larger ones.

@nicolo-ribaudo one quick question, the generators in make throw an error if the folders don't exist for the output of a template/case file, so I've just been making them manually. I couldn't figure out the command to run to not throw, is there a way to do that easily?

pzuraq avatar Jun 02 '24 16:06 pzuraq

This PR is now ready for review. There are some tests that are failing against the Babel test runner that I can't figure out:

  1. Some class expression tests are failing due to a Babel transpilation error, var C is already declared for some reason. The code is valid and should work, and it transpiles fine in the Babel playground, so I'm not sure what the issue is there.
  2. Some tests that rely on Proxy are failing because Proxy is undefined. I did add the feature flag for it, so I'm not sure what else I need to do to make Proxy available.
  3. The tests for a class decorator returning a non-[[Construct]] arrow function are failing, this is something that the Babel transform does not check for (not sure if it realistically can check for this).

I believe that's it though.

The tests should cover the bulk of decorator behavior, there may be some small gaps but we can address those in followups, this is already a massive PR and I don't want to continue adding to it.

pzuraq avatar Jun 06 '24 14:06 pzuraq

@pzuraq We discussed this in yesterday's test262 meeting. We plan to start reviewing it after tackling one other large PR that's been waiting longer.

In the meantime, would you mind splitting the commit on this branch into two commits, one with any hand-written changes and one with autogenerated changes? We'll focus on the former.

ptomato avatar Aug 15 '24 22:08 ptomato

Ok, sounds good! I can get that done likely by the end of the month or early next month.

pzuraq avatar Aug 16 '24 12:08 pzuraq

@pzuraq I went ahead and investigated which tests were autogenerated — it looks like they all are! :smile:

A few of them don't have corresponding templates in src/, maybe you forgot to add some files?

  • src/decorator/field-context-kind.case
  • src/decorator/field-initializers-interleave.case
  • src/decorator/field-instance-initializer-order.case
  • src/decorator/field-received-value.case
  • src/decorator/field-static-initializer-order.case
  • src/decorator/decorator-test-123.case

ptomato avatar Oct 15 '24 19:10 ptomato

@ptomato ah those files were mistakenly added actually, they were work in progress files as I was working out the way the generator system worked. Removing them and rebasing now.

pzuraq avatar Feb 18 '25 21:02 pzuraq

The diff is quite big, I didn't read all, but it will good to add this case to tests if missing.

class A {
  @decorators[0]
  method() {}
}

fisker avatar May 14 '25 14:05 fisker