-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
test: update WPT encoding tests and run WPT in subdirectories #27860
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d0efc5
test: expect wpt/encoding/streams to fail
joyeecheung aca5d75
test: run WPT in subdirectories
joyeecheung 45e4391
test: update wpt/encoding to 7287608f90
joyeecheung bea3f04
test: expect wpt/encoding/encodeInto.any.js to fail
joyeecheung e9d7927
fixup! test: run WPT in subdirectories
joyeecheung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
[ | ||
{ | ||
"input": "Hi", | ||
"read": 0, | ||
"destinationLength": 0, | ||
"written": [] | ||
}, | ||
{ | ||
"input": "A", | ||
"read": 1, | ||
"destinationLength": 10, | ||
"written": [0x41] | ||
}, | ||
{ | ||
"input": "\u{1D306}", // "\uD834\uDF06" | ||
"read": 2, | ||
"destinationLength": 4, | ||
"written": [0xF0, 0x9D, 0x8C, 0x86] | ||
}, | ||
{ | ||
"input": "\u{1D306}A", | ||
"read": 0, | ||
"destinationLength": 3, | ||
"written": [] | ||
}, | ||
{ | ||
"input": "\uD834A\uDF06A¥Hi", | ||
"read": 5, | ||
"destinationLength": 10, | ||
"written": [0xEF, 0xBF, 0xBD, 0x41, 0xEF, 0xBF, 0xBD, 0x41, 0xC2, 0xA5] | ||
}, | ||
{ | ||
"input": "A\uDF06", | ||
"read": 2, | ||
"destinationLength": 4, | ||
"written": [0x41, 0xEF, 0xBF, 0xBD] | ||
}, | ||
{ | ||
"input": "¥¥", | ||
"read": 2, | ||
"destinationLength": 4, | ||
"written": [0xC2, 0xA5, 0xC2, 0xA5] | ||
} | ||
].forEach(testData => { | ||
[ | ||
{ | ||
"bufferIncrease": 0, | ||
"destinationOffset": 0, | ||
"filler": 0 | ||
}, | ||
{ | ||
"bufferIncrease": 10, | ||
"destinationOffset": 4, | ||
"filler": 0 | ||
}, | ||
{ | ||
"bufferIncrease": 0, | ||
"destinationOffset": 0, | ||
"filler": 0x80 | ||
}, | ||
{ | ||
"bufferIncrease": 10, | ||
"destinationOffset": 4, | ||
"filler": 0x80 | ||
}, | ||
{ | ||
"bufferIncrease": 0, | ||
"destinationOffset": 0, | ||
"filler": "random" | ||
}, | ||
{ | ||
"bufferIncrease": 10, | ||
"destinationOffset": 4, | ||
"filler": "random" | ||
} | ||
].forEach(destinationData => { | ||
test(() => { | ||
// Setup | ||
const bufferLength = testData.destinationLength + destinationData.bufferIncrease, | ||
destinationOffset = destinationData.destinationOffset, | ||
destinationLength = testData.destinationLength, | ||
destinationFiller = destinationData.filler, | ||
encoder = new TextEncoder(), | ||
buffer = new ArrayBuffer(bufferLength), | ||
view = new Uint8Array(buffer, destinationOffset, destinationLength), | ||
fullView = new Uint8Array(buffer), | ||
control = new Array(bufferLength); | ||
let byte = destinationFiller; | ||
for (let i = 0; i < bufferLength; i++) { | ||
if (destinationFiller === "random") { | ||
byte = Math.floor(Math.random() * 256); | ||
} | ||
control[i] = byte; | ||
fullView[i] = byte; | ||
} | ||
|
||
// It's happening | ||
const result = encoder.encodeInto(testData.input, view); | ||
|
||
// Basics | ||
assert_equals(view.byteLength, destinationLength); | ||
assert_equals(view.length, destinationLength); | ||
|
||
// Remainder | ||
assert_equals(result.read, testData.read); | ||
assert_equals(result.written, testData.written.length); | ||
for (let i = 0; i < bufferLength; i++) { | ||
if (i < destinationOffset || i >= (destinationOffset + testData.written.length)) { | ||
assert_equals(fullView[i], control[i]); | ||
} else { | ||
assert_equals(fullView[i], testData.written[i - destinationOffset]); | ||
} | ||
} | ||
}, "encodeInto() with " + testData.input + " and destination length " + testData.destinationLength + ", offset " + destinationData.destinationOffset + ", filler " + destinationData.filler); | ||
}); | ||
}); | ||
|
||
[DataView, | ||
Int8Array, | ||
Int16Array, | ||
Int32Array, | ||
Uint16Array, | ||
Uint32Array, | ||
Uint8ClampedArray, | ||
Float32Array, | ||
Float64Array].forEach(view => { | ||
test(() => { | ||
assert_throws(new TypeError(), () => new TextEncoder().encodeInto("", new view(new ArrayBuffer(0)))); | ||
}, "Invalid encodeInto() destination: " + view); | ||
}); | ||
|
||
test(() => { | ||
assert_throws(new TypeError(), () => new TextEncoder().encodeInto("", new ArrayBuffer(10))); | ||
}, "Invalid encodeInto() destination: ArrayBuffer"); | ||
|
||
test(() => { | ||
const buffer = new ArrayBuffer(10), | ||
view = new Uint8Array(buffer); | ||
let { read, written } = new TextEncoder().encodeInto("", view); | ||
assert_equals(read, 0); | ||
assert_equals(written, 0); | ||
new MessageChannel().port1.postMessage(buffer, [buffer]); | ||
({ read, written } = new TextEncoder().encodeInto("", view)); | ||
assert_equals(read, 0); | ||
assert_equals(written, 0); | ||
({ read, written } = new TextEncoder().encodeInto("test", view)); | ||
assert_equals(read, 0); | ||
assert_equals(written, 0); | ||
}, "encodeInto() and a detached output buffer"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/fixtures/wpt/encoding/textdecoder-fatal-single-byte.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 try to finish the feature encodeInto, after I finished I tested it with the test cases, but meet the failure as followed