From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../prototype/getFloat16/toindex-byteoffset.js | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js (limited to 'js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js') diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js new file mode 100644 index 0000000000..ae51364d35 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js @@ -0,0 +1,53 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getFloat16 +description: > + ToIndex conversions on byteOffset +features: [Float16Array, DataView.prototype.setUint8] +---*/ + +var buffer = new ArrayBuffer(6); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 75); +sample.setUint8(1, 76); +sample.setUint8(2, 77); +sample.setUint8(3, 78); +sample.setUint8(4, 79); +sample.setUint8(5, 80); + +var obj1 = { + valueOf: function() { + return 3; + } +}; + +var obj2 = { + toString: function() { + return 2; + } +}; + +assert.sameValue(sample.getFloat16(-0), 14.59375, "-0"); +assert.sameValue(sample.getFloat16(obj1), 25.234375, "object's valueOf"); +assert.sameValue(sample.getFloat16(obj2), 21.21875, "object's toString"); +assert.sameValue(sample.getFloat16(""), 14.59375, "the Empty string"); +assert.sameValue(sample.getFloat16("0"), 14.59375, "string '0'"); +assert.sameValue(sample.getFloat16("2"), 21.21875, "string '2'"); +assert.sameValue(sample.getFloat16(true), 17.203125, "true"); +assert.sameValue(sample.getFloat16(false), 14.59375, "false"); +assert.sameValue(sample.getFloat16(NaN), 14.59375, "NaN"); +assert.sameValue(sample.getFloat16(null), 14.59375, "null"); +assert.sameValue(sample.getFloat16(0.1), 14.59375, "0.1"); +assert.sameValue(sample.getFloat16(0.9), 14.59375, "0.9"); +assert.sameValue(sample.getFloat16(1.1), 17.203125, "1.1"); +assert.sameValue(sample.getFloat16(1.9), 17.203125, "1.9"); +assert.sameValue(sample.getFloat16(-0.1), 14.59375, "-0.1"); +assert.sameValue(sample.getFloat16(-0.99999), 14.59375, "-0.99999"); +assert.sameValue(sample.getFloat16(undefined), 14.59375, "undefined"); +assert.sameValue(sample.getFloat16(), 14.59375, "no arg"); + +reportCompare(0, 0); -- cgit v1.2.3