-
Notifications
You must be signed in to change notification settings - Fork 462
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
Improve tests for CreateByteDataBlock #3826
base: main
Are you sure you want to change the base?
Conversation
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 for your contribution! This looks correct to me.
Personally I didn't mind having the 2⁵³-1 case in the test corpus as a test of "If it is impossible to create such a Data Block, throw a RangeError exception", but I can also see the point of view that it is not a 100% reliable test.
I'm not sure what the |
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.
Please revert the changes to this file, because tc39/ecma262#3052 can't be tested using the ArrayBuffer
constructor:
The ArrayBuffer constructor applies ToIndex on its input parameter. ToIndex
throws a RangeError when the input number is >253-1. So the observed RangeError after modifying the file isn't thrown from CreateByteDataBlock
, but instead it's thrown from ToIndex
.
@anba That's true, but we're also not going to advance an iterator 253 times to hit that guard. These tests are still valid, though, and an improvement. How do you suggest we test tc39/ecma262#3052? |
Yes, they're valid, but they test a different code path. If we want to keep them, they should be placed into a new file.
TypedArray constructors should hit the new range check in CreateByteDataBlock:
|
Hey @michaelficarra @ptomato, just letting you know since I had your approval for the PR, if @anba's suggestion sounds good I will start working on creating the tests under TypedArray constructor(s). Do you still want to merge these improvements to |
@anba You're right, I wasn't aware of the multiplication in @dewren99 I still like these changes as-is, but they don't exercise tc39/ecma262#3052. It's up to @ptomato and @tc39/test262-maintainers whether we should include those tests in this PR or make a separate one. If you want to get started right away, it'd probably be safest to just open a separate PR with those tests. |
It's fine to include them in this PR as far as I'm concerned. Are you planning to adopt @anba's suggestion of placing these tests in a different file, as well? |
@ptomato I haven't had the chance to look if there are already tests for Or do you have recommendation on where I should add them? If it fine I can just update this PR to include new tests too. |
I'm not too familiar with the TypedArray constructors tests, but @jugglinmike might be able to answer that question. |
Please see the discussion on tc39/ecma262#3052