test262 icon indicating copy to clipboard operation
test262 copied to clipboard

Improve tests for CreateByteDataBlock

Open dewren99 opened this issue 2 years ago • 8 comments
trafficstars

Please see the discussion on https://github.com/tc39/ecma262/pull/3052

dewren99 avatar May 11 '23 17:05 dewren99

I'm not sure what the [NotSupported] ArrayBuffer output means in esmeta. @jhnaldo is this an expected failure?

ptomato avatar May 18 '23 18:05 ptomato

because tc39/ecma262#3052 can't be tested using the ArrayBuffer constructor:

@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?

michaelficarra avatar Jun 06 '23 16:06 michaelficarra

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.

How do you suggest we test https://github.com/tc39/ecma262/pull/3052?

TypedArray constructors should hit the new range check in CreateByteDataBlock: TypedArrayAllocateTypedArrayAllocateTypedArrayBufferAllocateArrayBufferCreateByteDataBlock

AllocateTypedArrayBuffer performs elementSize × length, where length is a user-input coerced through ToIndex and elementSize is an integer in [1, 2, 4, 8]. So new Int16Array(2 ** 52) should hit the new range check, right?

anba avatar Jun 06 '23 16:06 anba

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 CreateByteDataBlock tests under a different PR or should I keep this PR open?

dewren99 avatar Jun 08 '23 21:06 dewren99

@anba You're right, I wasn't aware of the multiplication in AllocateTypedArrayBuffer step 3. So there's a way to trigger it other than iterating. Thanks.

@dewren99 I still like these changes as-is, but they don't exercise https://github.com/tc39/ecma262/pull/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.

michaelficarra avatar Jun 08 '23 21:06 michaelficarra

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 avatar Jun 12 '23 10:06 ptomato

@ptomato I haven't had the chance to look if there are already tests for TypedArray constructor(s), but if there are, I was thinking about adding the new tests there. Otherwise I was going to create a new file for the tests.

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.

dewren99 avatar Jun 12 '23 16:06 dewren99

I'm not too familiar with the TypedArray constructors tests, but @jugglinmike might be able to answer that question.

ptomato avatar Jun 13 '23 08:06 ptomato