-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Encoding: encodeInto() #14505
Encoding: encodeInto() #14505
Conversation
I found it a little hard to write tests without an implementation, but I think this framework is adequate for any number of tests we'd want to write. Probably at this point it's most helpful to review that framework and then when implementations start we can fill out the number of tests? |
Looks good. I think this is a good framework to test Edit: I think we will need a separate test that bytes after the last written codepoint are not modified. With this test framework we can't tell whether they're left alone or overwritten with null bytes. |
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.
Looks good to me. Thanks.
To test an edge case that's hard for encoding_rs, it would be good to add a test whose output buffer size is 4 and whose input is an ASCII character followed by a snowman (or other 3-bytes-as-UTF-8 character).
Also: Output buffer size 4 and input contains two 2-bytes-as-UTF-8 characters.
Mentioned on the spec PR but: Needs cases where the destination view is offset/subset of the backing array buffer, e.g. const ab = new ArrayBuffer(5);
const view = new Uint8Array(ab, 1, 2);
new TextEncoder().encodeInto("ABCDE", view); |
I wrote tests for more complicated view setups which was a lot of fun, but an implementation would be good at this point as I'm worried for off-by-one errors. (I also added Henri's tests. I think I covered everything now.) |
I've written all the various tests requested thus far, I think, including some additional ones I thought of myself. |
a7c5cd0
to
60bfa1e
Compare
FYI, I've rebased this branch to trigger "Travis CI - Pull Request", manually setting things right after the travis-ci.com transition in #14499 changed the name of the required check, which applies retroactively. |
Does someone want to review the additions? |
@foolip, the chrome[experimental] and firefox[experimental] tasks started 20 days ago but don't show up as finished. |
@lukebjerring can you take a look at what's going on with the wpt.fyi checks? I guess this is web-platform-tests/wpt.fyi#950. |
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.
I wrote a slow and dumb polyfill. With the change I noted the tests pass.
Yep, attempting to update says:
|
I plan to land these tomorrow, together with the change to the Encoding Standard. Thanks for the review @ricea! |
Looks like @Hexcles has succeeded in uploading empty reports 🎉 Please fix that before this lands. |
@lukebjerring can you reproduce it? I can't. |
This enables converting strings into UTF-8 byte sequences reusing a pre-allocated output buffer. Also cleans up TextEncoder a bit. Tests: web-platform-tests/wpt#14505. Fixes #69.
… r=hsivonen. web-platform-tests/wpt#14505 web-platform-tests/wpt#14775 UltraBlame original commit: 3c73631c8237077acb3795e51a2a2ea6016247df
… r=hsivonen. web-platform-tests/wpt#14505 web-platform-tests/wpt#14775 UltraBlame original commit: 3c73631c8237077acb3795e51a2a2ea6016247df
… r=hsivonen. web-platform-tests/wpt#14505 web-platform-tests/wpt#14775 UltraBlame original commit: 3c73631c8237077acb3795e51a2a2ea6016247df
For whatwg/encoding#166.