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 / toHex / receiver-not-uint8array.js
blob1409cca969f0cfb206c69bfda156bb35d3e98521
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.tohex
6 description: Uint8Array.prototype.toHex throws if the receiver is not a Uint8Array
7 includes: [testTypedArray.js]
8 features: [uint8array-base64, TypedArray]
9 ---*/
11 var toHex = Uint8Array.prototype.toHex;
13 testWithTypedArrayConstructors(function(TA) {
14   if (TA === Uint8Array) return;
15   var sample = new TA(2);
16   assert.throws(TypeError, function() {
17     Uint8Array.prototype.toHex.call(sample);
18   });
19 });
21 assert.throws(TypeError, function() {
22   Uint8Array.prototype.toHex.call([]);
23 });
25 assert.throws(TypeError, function() {
26   toHex();
27 });
29 reportCompare(0, 0);