Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (DESCRIPTORS) QUnit.test('Float64 conversions', assert => {
const float64array = new Float64Array(1);
const uint8array = new Uint8Array(float64array.buffer);
const dataview = new DataView(float64array.buffer);
function viewFrom(it) {
return new DataView(new Uint8Array(it).buffer);
}
function toString(it) {
return it === 0 && 1 / it === -Infinity ? '-0' : it;
}
const data = [
[0, 0, [0, 0, 0, 0, 0, 0, 0, 0]],
[-0, -0, [0, 0, 0, 0, 0, 0, 0, 128]],
[1, 1, [0, 0, 0, 0, 0, 0, 240, 63]],
[-1, -1, [0, 0, 0, 0, 0, 0, 240, 191]],
[1.1, 1.1, [154, 153, 153, 153, 153, 153, 241, 63]],
[-1.1, -1.1, [154, 153, 153, 153, 153, 153, 241, 191]],
if (DESCRIPTORS) QUnit.test('Int16 conversions', assert => {
const int16array = new Int16Array(1);
const uint8array = new Uint8Array(int16array.buffer);
const dataview = new DataView(int16array.buffer);
function viewFrom(it) {
return new DataView(new Uint8Array(it).buffer);
}
function toString(it) {
return it === 0 && 1 / it === -Infinity ? '-0' : it;
}
let data = [
[0, 0, [0, 0]],
[-0, 0, [0, 0]],
[1, 1, [1, 0]],
[-1, -1, [255, 255]],
[1.1, 1, [1, 0]],
[-1.1, -1, [255, 255]],
QUnit.test('DataView accessors', assert => {
const uint8array = new Uint8Array(8);
const dataview = new DataView(uint8array.buffer);
assert.arrayEqual(uint8array, [0, 0, 0, 0, 0, 0, 0, 0]);
dataview.setUint8(0, 255);
assert.arrayEqual(uint8array, [0xff, 0, 0, 0, 0, 0, 0, 0]);
dataview.setInt8(1, -1);
assert.arrayEqual(uint8array, [0xff, 0xff, 0, 0, 0, 0, 0, 0]);
dataview.setUint16(2, 0x1234);
assert.arrayEqual(uint8array, [0xff, 0xff, 0x12, 0x34, 0, 0, 0, 0]);
dataview.setInt16(4, -1);
assert.arrayEqual(uint8array, [0xff, 0xff, 0x12, 0x34, 0xff, 0xff, 0, 0]);
dataview.setUint32(1, 0x12345678);
assert.arrayEqual(uint8array, [0xff, 0x12, 0x34, 0x56, 0x78, 0xff, 0, 0]);
dataview.setInt32(4, -2023406815);
assert.arrayEqual(uint8array, [0xff, 0x12, 0x34, 0x56, 0x87, 0x65, 0x43, 0x21]);
dataview.setFloat32(2, 1.2e+38);
assert.arrayEqual(uint8array, [0xff, 0x12, 0x7e, 0xb4, 0x8e, 0x52, 0x43, 0x21]);
if (DESCRIPTORS) QUnit.test('Uint8Clamped conversions', assert => {
const uint8clamped = new Uint8ClampedArray(1);
const uint8array = new Uint8Array(uint8clamped.buffer);
function toString(it) {
return it === 0 && 1 / it === -Infinity ? '-0' : it;
}
const data = [
[0, 0, [0]],
[-0, 0, [0]],
[1, 1, [1]],
[-1, 0, [0]],
[1.1, 1, [1]],
[-1.1, 0, [0]],
[1.9, 2, [2]],
[-1.9, 0, [0]],
[127, 127, [127]],
[-127, 0, [0]],
function viewFrom(it) {
return new DataView(new Uint8Array(it).buffer);
}
function toString(it) {
function viewFrom(it) {
return new DataView(new Uint8Array(it).buffer);
}
function toString(it) {
function viewFrom(it) {
return new DataView(new Uint8Array(it).buffer);
}
function toString(it) {
function viewFrom(it) {
return new DataView(new Uint8Array(it).buffer);
}
function toString(it) {