Bug 1885337 - Part 3: Import tests from test262 PR. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / prs / 3994 / built-ins / Uint8Array / prototype / setFromHex / illegal-characters.js
blob1c30b4cffd56620ae136eb181269ab6d276129b4
1 // |reftest| shell-option(--enable-uint8array-base64) skip-if(!Uint8Array.fromBase64||!xulRuntime.shell) -- uint8array-base64 is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Kevin Gibbons. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-uint8array.prototype.setfromhex
6 description: Uint8Array.prototype.setFromHex throws a SyntaxError when input has non-hex characters
7 features: [uint8array-base64, TypedArray]
8 ---*/
10 var illegal = [
11   'a.a',
12   'aa^',
13   'a a',
14   'a\ta',
15   'a\x0Aa',
16   'a\x0Ca',
17   'a\x0Da',
18   'a\u00A0a', // nbsp
19   'a\u2009a', // thin space
20   'a\u2028a', // line separator
22 illegal.forEach(function(value) {
23   assert.throws(SyntaxError, function() {
24     var target = new Uint8Array([255, 255, 255, 255, 255]);
25     target.setFromHex(value);
26   });
27 });
29 reportCompare(0, 0);