Bug 1894428 - Set depended on bit from AutoStableStringChars r=sfink
[gecko.git] / js / src / tests / test262 / built-ins / DataView / prototype / setFloat16 / negative-byteoffset-throws.js
blob84722723ad1560c1d4e16f79f7ae1cd77d274631
1 // |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array 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.
5 /*---
6 esid: sec-dataview.prototype.setfloat16
7 description: >
8   Throws a RangeError if getIndex < 0
9 features: [Float16Array]
10 ---*/
12 var buffer = new ArrayBuffer(12);
13 var sample = new DataView(buffer, 0);
15 assert.throws(RangeError, function() {
16   sample.setFloat16(-1, 39);
17 }, "-1");
18 assert.sameValue(sample.getFloat32(0), 0, "-1 - no value was set");
20 assert.throws(RangeError, function() {
21   sample.setFloat16(-Infinity, 39);
22 }, "-Infinity");
23 assert.sameValue(sample.getFloat32(0), 0, "-Infinity - no value was set");
25 reportCompare(0, 0);