test262 icon indicating copy to clipboard operation
test262 copied to clipboard

add tests for base64 proposal

Open bakkot opened this issue 1 year ago • 10 comments

Proposal repo.

~It's only stage 2, so I'm marking this as a draft for now. I'm hoping to ask for stage 3 at the coming meeting, and that requires "sufficient" test262 tests (but they don't require approval by maintainers, so this review of this PR need to be rushed).~ Proposal is stage 3, this is ready for review/landing.

bakkot avatar Jan 22 '24 01:01 bakkot

The lint failure is silly - the new "uint8array-base64" feature presumably implies the existence of TypedArrays, so I don't think the "TypedArray" feature should need to be included.

I could do so anyway if it's too much trouble to fix the linter, I guess.

bakkot avatar Jan 22 '24 01:01 bakkot

Sure, I can add tests for that, though in any real implementation I would expect that to be covered by option-coercion tests, which confirm that ToString is not called.

(This behavior is very much intentional.)

bakkot avatar Jan 26 '24 16:01 bakkot

@bakkot features are often handled by an exclude list, not an include list, so a runner could exclude typed arrays and not know to exclude this one. it'd be good to add it in explicitly to the test files.

ljharb avatar Jan 26 '24 17:01 ljharb

Marked as ready for review since the proposal is now stage 3.

bakkot avatar Feb 21 '24 02:02 bakkot

I've addressed comments and hopefully pleased the linter.

@ljharb I see you force-pushed to my branch but I have no idea what changes that included. I'm hoping it's just a rebase but I'm not reading a 10k line diff. I force-pushed over your changes, whatever they were.

bakkot avatar Mar 12 '24 06:03 bakkot

@bakkot oh, i just clicked the "rebase branch" button in the PR; i didn't change anything. fine to force push over.

ljharb avatar Mar 12 '24 06:03 ljharb

If you do "update with merge commit" instead of "update with rebase" it'll create a merge commit, which allows git pull --rebase, which is much friendlier. Since the PR will get squashed before merging to main anyway the merge commit will go away eventually.

bakkot avatar Mar 12 '24 06:03 bakkot

Merge commits are anathema, even on a PR, so that's not a good idea - git pull --rebase should work fine with a rebased branch.

ljharb avatar Mar 12 '24 06:03 ljharb

Sorry, --ff-only, maybe? One of them doesn't work with rebases, I'm pretty sure.

Anyway, the merge commits at least make it easy to tell that it's just an update of the branch, whereas that's not obvious when doing a rebase. Something to discuss elsewhere, though.

bakkot avatar Mar 12 '24 07:03 bakkot

Ideas for additional coverage:

  • Whitespace between and after the padding character =, e.g. Uint8Array.fromBase64("Zg= =") and Uint8Array.fromBase64("Zg= = ").
  • Uint8Array.prototype.setFrom{Base64,Hex} doesn't modify the typed array when the input string is invalid.
  • Typed array is backed by a SharedArrayBuffer.
  • lastChunkHandling option is present, but set to undefined, e.g. the options object is {lastChunkHandling: undefined}.
  • lastChunkHandling option is an invalid string value, e.g. the options object is {lastChunkHandling: "bad"}.
  • alphabet option is present, but set to undefined, e.g. the options object is {alphabet: undefined}.
  • alphabet and lastChunkHandling options are read in the correct order.
  • Extra bits with three element trailing chunk and strict chunk handling, e.g. Uint8Array.fromBase64("ZZZ=", {lastChunkHandling: "strict"}). (The two element chunk case is already covered.)

anba avatar Mar 14 '24 15:03 anba