mirror of
https://github.com/tc39/test262.git
synced 2025-07-24 06:25:30 +02:00
Add coverage for odd string lengths in Uint8Array.prototype.setFromHex
V8 doesn't handle this correctly for zero length typed arrays.
This commit is contained in:
parent
8649d5e117
commit
7c9314b06b
40
test/built-ins/Uint8Array/prototype/setFromHex/throws-when-string-length-is-odd.js
vendored
Normal file
40
test/built-ins/Uint8Array/prototype/setFromHex/throws-when-string-length-is-odd.js
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-uint8array.prototype.setfromhex
|
||||||
|
description: >
|
||||||
|
Throws a SyntaxError when the string length is odd.
|
||||||
|
info: |
|
||||||
|
Uint8Array.prototype.setFromHex ( string )
|
||||||
|
|
||||||
|
...
|
||||||
|
7. Let result be FromHex(string, byteLength).
|
||||||
|
...
|
||||||
|
13. If result.[[Error]] is not none, then
|
||||||
|
a. Throw result.[[Error]].
|
||||||
|
...
|
||||||
|
|
||||||
|
FromHex ( string [ , maxLength ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If length modulo 2 is not 0, then
|
||||||
|
a. Let error be a new SyntaxError exception.
|
||||||
|
b. Return the Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }.
|
||||||
|
...
|
||||||
|
|
||||||
|
features: [TypedArray, uint8array-base64]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var zeroLength = new Uint8Array(0);
|
||||||
|
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
zeroLength.setFromHex("1")
|
||||||
|
}, "Uint8Array has length 0");
|
||||||
|
|
||||||
|
|
||||||
|
var nonZeroLength = new Uint8Array(1);
|
||||||
|
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
nonZeroLength.setFromHex("1")
|
||||||
|
}, "Uint8Array has length >0");
|
Loading…
x
Reference in New Issue
Block a user