mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 20:37:31 +09:00
Issue #2838 - Update tests
This commit is contained in:
parent
c07ea665ea
commit
fcc58bfbba
5 changed files with 43 additions and 13 deletions
|
|
@ -69,8 +69,8 @@ assertEq(asmLink(asmCompile('glob', USE_ASM + 'var im=glob.Math.imul; function f
|
||||||
|
|
||||||
var module = asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f');
|
var module = asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f');
|
||||||
assertAsmLinkAlwaysFail(module, null, null);
|
assertAsmLinkAlwaysFail(module, null, null);
|
||||||
assertAsmLinkAlwaysFail(module, this, null, null);
|
assertAsmLinkFail(module, this, null, null);
|
||||||
assertAsmLinkAlwaysFail(module, this, null, null);
|
assertAsmLinkFail(module, this, null, null);
|
||||||
assertAsmLinkAlwaysFail(module, this, null, new ArrayBuffer(1));
|
assertAsmLinkAlwaysFail(module, this, null, new ArrayBuffer(1));
|
||||||
assertAsmLinkFail(module, this, null, new ArrayBuffer(4));
|
assertAsmLinkFail(module, this, null, new ArrayBuffer(4));
|
||||||
assertAsmLinkFail(module, this, null, new ArrayBuffer(100));
|
assertAsmLinkFail(module, this, null, new ArrayBuffer(100));
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ try {
|
||||||
var buf = new Uint8ClampedArray(a);
|
var buf = new Uint8ClampedArray(a);
|
||||||
throw new Error("didn't throw");
|
throw new Error("didn't throw");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assertEq(e instanceof TypeError, true,
|
assertEq(e instanceof RangeError, true,
|
||||||
"expected TypeError, instead threw: " + e);
|
"expected RangeError, instead threw: " + e);
|
||||||
caughtInvalidArguments = true;
|
caughtInvalidArguments = true;
|
||||||
}
|
}
|
||||||
assertEq(caughtInvalidArguments, true);
|
assertEq(caughtInvalidArguments, true);
|
||||||
|
|
@ -20,8 +20,8 @@ while (true) {
|
||||||
assertEq(buf.length, 300);
|
assertEq(buf.length, 300);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assertEq(a, -1);
|
assertEq(a, -1);
|
||||||
assertEq(e instanceof TypeError, true,
|
assertEq(e instanceof RangeError, true,
|
||||||
"expected TypeError, instead threw: " + e);
|
"expected RangeError, instead threw: " + e);
|
||||||
caughtInvalidArguments = true;
|
caughtInvalidArguments = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -38,8 +38,8 @@ while (true) {
|
||||||
assertEq(buf.length, 0);
|
assertEq(buf.length, 0);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assertEq(a, -1);
|
assertEq(a, -1);
|
||||||
assertEq(e instanceof TypeError, true,
|
assertEq(e instanceof RangeError, true,
|
||||||
"expected TypeError, instead threw: " + e);
|
"expected RangeError, instead threw: " + e);
|
||||||
caughtInvalidArguments = true;
|
caughtInvalidArguments = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
new Function(`
|
new Function(`
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
var buf = new Uint8ClampedArray(a);
|
var buf = new Uint8ClampedArray(-1);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Test that all TypedArray constructor variants throw a RangeError when
|
||||||
|
// attempting to create a too large array.
|
||||||
|
|
||||||
|
// The maximum typed array length is (currently) limited to
|
||||||
|
// `(INT32_MAX / BYTES_PER_ELEMENT) - 1`.
|
||||||
|
|
||||||
|
const INT32_MAX = 2**31 - 1;
|
||||||
|
|
||||||
|
// 22.2.4.2 TypedArray ( length )
|
||||||
|
for (let TA of typedArrayConstructors) {
|
||||||
|
assertThrows(() => new TA(INT32_MAX), RangeError);
|
||||||
|
assertThrows(() => new TA(INT32_MAX >> Math.log2(TA.BYTES_PER_ELEMENT)), RangeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test disabled because allocating a 2**30 Int8Array easily leads to OOMs.
|
||||||
|
//
|
||||||
|
// 22.2.4.3 TypedArray ( typedArray )
|
||||||
|
// const largeInt8Array = new Int8Array(2**30);
|
||||||
|
// for (let TA of typedArrayConstructors.filter(c => c.BYTES_PER_ELEMENT > 1)) {
|
||||||
|
// assertThrows(() => new TA(largeInt8Array), RangeError);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 22.2.4.4 TypedArray ( object )
|
||||||
|
for (let TA of typedArrayConstructors) {
|
||||||
|
assertThrows(() => new TA({length: INT32_MAX}), RangeError);
|
||||||
|
assertThrows(() => new TA({length: INT32_MAX >> Math.log2(TA.BYTES_PER_ELEMENT)}), RangeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof reportCompare === "function")
|
||||||
|
reportCompare(true, true);
|
||||||
|
|
@ -436,7 +436,7 @@ function test()
|
||||||
a = new ArrayBuffer(0x10);
|
a = new ArrayBuffer(0x10);
|
||||||
checkThrows(() => new Uint32Array(buffer, 4, 0x3FFFFFFF));
|
checkThrows(() => new Uint32Array(buffer, 4, 0x3FFFFFFF));
|
||||||
|
|
||||||
checkThrows(() => new Float32Array(null));
|
check(() => new Float32Array(null).length === 0);
|
||||||
|
|
||||||
a = new Uint8Array(0x100);
|
a = new Uint8Array(0x100);
|
||||||
b = Uint32Array.prototype.subarray.apply(a, [0, 0x100]);
|
b = Uint32Array.prototype.subarray.apply(a, [0, 0x100]);
|
||||||
|
|
@ -496,9 +496,9 @@ function test()
|
||||||
check(() => (new Float32Array(Math.sqrt(4))).length == 2);
|
check(() => (new Float32Array(Math.sqrt(4))).length == 2);
|
||||||
check(() => (new Float32Array({ length: 10 })).length == 10);
|
check(() => (new Float32Array({ length: 10 })).length == 10);
|
||||||
check(() => (new Float32Array({})).length == 0);
|
check(() => (new Float32Array({})).length == 0);
|
||||||
checkThrows(() => new Float32Array("3"));
|
check(() => new Float32Array("3").length === 3);
|
||||||
checkThrows(() => new Float32Array(null));
|
check(() => new Float32Array(null).length === 0);
|
||||||
checkThrows(() => new Float32Array(undefined));
|
check(() => new Float32Array(undefined).length === 0);
|
||||||
|
|
||||||
// check that NaN conversions happen correctly with array conversions
|
// check that NaN conversions happen correctly with array conversions
|
||||||
check(() => (new Int32Array([NaN])[0]) == 0);
|
check(() => (new Int32Array([NaN])[0]) == 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue