Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TextEncoder/TextDecoder SharedArrayBuffer tests
Add tests for TextEncoder/TextDecoder with SharedArrayBuffer
- Loading branch information
Showing
3 changed files
with
121 additions
and
101 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
test(() => { | ||
const buf = new ArrayBuffer(2), | ||
view = new Uint8Array(buf), | ||
buf2 = new ArrayBuffer(2), | ||
view2 = new Uint8Array(buf2), | ||
decoder = new TextDecoder("utf-8") | ||
view[0] = 0xEF | ||
view[1] = 0xBB | ||
view2[0] = 0xBF | ||
view2[1] = 0x40 | ||
assert_equals(decoder.decode(buf, {stream:true}), "") | ||
view[0] = 0x01 | ||
view[1] = 0x02 | ||
assert_equals(decoder.decode(buf2), "@") | ||
}, "Modify buffer after passing it in") | ||
[ArrayBuffer, self["SharedArrayBuffer"]].forEach((ArrayBufferOrSharedArrayBuffer) => { | ||
test(() => { | ||
const buf = new ArrayBufferOrSharedArrayBuffer(2), | ||
view = new Uint8Array(buf), | ||
buf2 = new ArrayBufferOrSharedArrayBuffer(2), | ||
view2 = new Uint8Array(buf2), | ||
decoder = new TextDecoder("utf-8") | ||
view[0] = 0xEF | ||
view[1] = 0xBB | ||
view2[0] = 0xBF | ||
view2[1] = 0x40 | ||
assert_equals(decoder.decode(buf, {stream:true}), "") | ||
view[0] = 0x01 | ||
view[1] = 0x02 | ||
assert_equals(decoder.decode(buf2), "@") | ||
}, "Modify buffer after passing it in (" + ArrayBufferOrSharedArrayBuffer.name + ")") | ||
}); |
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