Bug 1149015 - Part 2: Remove some use of expression closure from jstests js1_8_5/extensions. r=luke

This commit is contained in:
Tooru Fujisawa 2015-04-01 18:34:02 +09:00
parent 7bd7692f49
commit 163479c9aa
3 changed files with 462 additions and 462 deletions

View File

@ -56,13 +56,13 @@ function test() {
// testConstructor
buffer = (new Uint8Array([1, 2])).buffer;
checkThrow(function () new DataView(buffer, 0, 3), RangeError);
checkThrow(function () new DataView(buffer, 1, 2), RangeError);
checkThrow(function () new DataView(buffer, 2, 1), RangeError);
checkThrow(function () new DataView(buffer, 2147483649, 0), RangeError);
checkThrow(function () new DataView(buffer, 0, 2147483649), RangeError);
checkThrow(function() new DataView(), TypeError);
checkThrow(function() new DataView(Object.create(new ArrayBuffer(5))), TypeError);
checkThrow(() => new DataView(buffer, 0, 3), RangeError);
checkThrow(() => new DataView(buffer, 1, 2), RangeError);
checkThrow(() => new DataView(buffer, 2, 1), RangeError);
checkThrow(() => new DataView(buffer, 2147483649, 0), RangeError);
checkThrow(() => new DataView(buffer, 0, 2147483649), RangeError);
checkThrow(() => new DataView(), TypeError);
checkThrow(() => new DataView(Object.create(new ArrayBuffer(5))), TypeError);
// testGetMethods
@ -431,331 +431,331 @@ function test() {
var buffer12 = new Uint8Array(data12).buffer;
view = new DataView(buffer12, 3, 2);
assertEq(view.getInt8(0), 0);
checkThrow(function () view.getInt8(8), RangeError);
checkThrow(function () view.getInt8(15), RangeError);
checkThrow(() => view.getInt8(8), RangeError);
checkThrow(() => view.getInt8(15), RangeError);
assertEq(view.getUint8(0), 0);
checkThrow(function () view.getUint8(8), RangeError);
checkThrow(function () view.getUint8(15), RangeError);
checkThrow(() => view.getUint8(8), RangeError);
checkThrow(() => view.getUint8(15), RangeError);
// Little endian.
assertEq(view.getInt16(0, true), 256);
checkThrow(function () view.getInt16(5, true), RangeError);
checkThrow(function () view.getInt16(9, true), RangeError);
checkThrow(function () view.getInt16(14, true), RangeError);
checkThrow(() => view.getInt16(5, true), RangeError);
checkThrow(() => view.getInt16(9, true), RangeError);
checkThrow(() => view.getInt16(14, true), RangeError);
// Big endian.
assertEq(view.getInt16(0), 1);
checkThrow(function () view.getInt16(5), RangeError);
checkThrow(function () view.getInt16(9), RangeError);
checkThrow(function () view.getInt16(14), RangeError);
checkThrow(() => view.getInt16(5), RangeError);
checkThrow(() => view.getInt16(9), RangeError);
checkThrow(() => view.getInt16(14), RangeError);
// Little endian.
assertEq(view.getUint16(0, true), 256);
checkThrow(function () view.getUint16(5, true), RangeError);
checkThrow(function () view.getUint16(9, true), RangeError);
checkThrow(function () view.getUint16(14, true), RangeError);
checkThrow(() => view.getUint16(5, true), RangeError);
checkThrow(() => view.getUint16(9, true), RangeError);
checkThrow(() => view.getUint16(14, true), RangeError);
// Big endian.
assertEq(view.getUint16(0), 1);
checkThrow(function () view.getUint16(5), RangeError);
checkThrow(function () view.getUint16(9), RangeError);
checkThrow(function () view.getUint16(14), RangeError);
checkThrow(() => view.getUint16(5), RangeError);
checkThrow(() => view.getUint16(9), RangeError);
checkThrow(() => view.getUint16(14), RangeError);
// Little endian.
checkThrow(function () view.getInt32(0, true), RangeError);
checkThrow(function () view.getInt32(3, true), RangeError);
checkThrow(function () view.getInt32(6, true), RangeError);
checkThrow(function () view.getInt32(9, true), RangeError);
checkThrow(function () view.getInt32(12, true), RangeError);
checkThrow(() => view.getInt32(0, true), RangeError);
checkThrow(() => view.getInt32(3, true), RangeError);
checkThrow(() => view.getInt32(6, true), RangeError);
checkThrow(() => view.getInt32(9, true), RangeError);
checkThrow(() => view.getInt32(12, true), RangeError);
// Big endian.
checkThrow(function () view.getInt32(0), RangeError);
checkThrow(function () view.getInt32(3), RangeError);
checkThrow(function () view.getInt32(6), RangeError);
checkThrow(function () view.getInt32(9), RangeError);
checkThrow(function () view.getInt32(12), RangeError);
checkThrow(() => view.getInt32(0), RangeError);
checkThrow(() => view.getInt32(3), RangeError);
checkThrow(() => view.getInt32(6), RangeError);
checkThrow(() => view.getInt32(9), RangeError);
checkThrow(() => view.getInt32(12), RangeError);
// Little endian.
checkThrow(function () view.getUint32(0, true), RangeError);
checkThrow(function () view.getUint32(3, true), RangeError);
checkThrow(function () view.getUint32(6, true), RangeError);
checkThrow(function () view.getUint32(9, true), RangeError);
checkThrow(function () view.getUint32(12, true), RangeError);
checkThrow(() => view.getUint32(0, true), RangeError);
checkThrow(() => view.getUint32(3, true), RangeError);
checkThrow(() => view.getUint32(6, true), RangeError);
checkThrow(() => view.getUint32(9, true), RangeError);
checkThrow(() => view.getUint32(12, true), RangeError);
// Big endian.
checkThrow(function () view.getUint32(0), RangeError);
checkThrow(function () view.getUint32(3), RangeError);
checkThrow(function () view.getUint32(6), RangeError);
checkThrow(function () view.getUint32(9), RangeError);
checkThrow(function () view.getUint32(12), RangeError);
checkThrow(() => view.getUint32(0), RangeError);
checkThrow(() => view.getUint32(3), RangeError);
checkThrow(() => view.getUint32(6), RangeError);
checkThrow(() => view.getUint32(9), RangeError);
checkThrow(() => view.getUint32(12), RangeError);
// testFloatGets(start=3)
// testFloatGet expected=10
// Little endian
view = new DataView(buffer2, 3, 1);
checkThrow(function () view.getFloat32(0, true), RangeError);
checkThrow(() => view.getFloat32(0, true), RangeError);
view = new DataView(buffer2_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, true), RangeError);
checkThrow(() => view.getFloat32(3, true), RangeError);
view = new DataView(buffer2_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, true), RangeError);
checkThrow(() => view.getFloat32(7, true), RangeError);
view = new DataView(buffer2_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, true), RangeError);
checkThrow(() => view.getFloat32(10, true), RangeError);
// Big endian.
view = new DataView(buffer2_r, 3, 1);
checkThrow(function () view.getFloat32(0, false), RangeError);
checkThrow(() => view.getFloat32(0, false), RangeError);
view = new DataView(buffer2_r_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, false), RangeError);
checkThrow(() => view.getFloat32(3, false), RangeError);
view = new DataView(buffer2_r_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, false), RangeError);
checkThrow(() => view.getFloat32(7, false), RangeError);
view = new DataView(buffer2_r_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, false), RangeError);
checkThrow(() => view.getFloat32(10, false), RangeError);
// testFloatGet expected=1.2300000190734863
// Little endian
view = new DataView(buffer3, 3, 1);
checkThrow(function () view.getFloat32(0, true), RangeError);
checkThrow(() => view.getFloat32(0, true), RangeError);
view = new DataView(buffer3_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, true), RangeError);
checkThrow(() => view.getFloat32(3, true), RangeError);
view = new DataView(buffer3_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, true), RangeError);
checkThrow(() => view.getFloat32(7, true), RangeError);
view = new DataView(buffer3_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, true), RangeError);
checkThrow(() => view.getFloat32(10, true), RangeError);
// Big endian.
view = new DataView(buffer3_r, 3, 1);
checkThrow(function () view.getFloat32(0, false), RangeError);
checkThrow(() => view.getFloat32(0, false), RangeError);
view = new DataView(buffer3_r_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, false), RangeError);
checkThrow(() => view.getFloat32(3, false), RangeError);
view = new DataView(buffer3_r_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, false), RangeError);
checkThrow(() => view.getFloat32(7, false), RangeError);
view = new DataView(buffer3_r_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, false), RangeError);
checkThrow(() => view.getFloat32(10, false), RangeError);
// testFloatGet expected=-45621.37109375
// Little endian
view = new DataView(buffer4, 3, 1);
checkThrow(function () view.getFloat32(0, true), RangeError);
checkThrow(() => view.getFloat32(0, true), RangeError);
view = new DataView(buffer4_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, true), RangeError);
checkThrow(() => view.getFloat32(3, true), RangeError);
view = new DataView(buffer4_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, true), RangeError);
checkThrow(() => view.getFloat32(7, true), RangeError);
view = new DataView(buffer4_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, true), RangeError);
checkThrow(() => view.getFloat32(10, true), RangeError);
// Big endian.
view = new DataView(buffer4_r, 3, 1);
checkThrow(function () view.getFloat32(0, false), RangeError);
checkThrow(() => view.getFloat32(0, false), RangeError);
view = new DataView(buffer4_r_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, false), RangeError);
checkThrow(() => view.getFloat32(3, false), RangeError);
view = new DataView(buffer4_r_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, false), RangeError);
checkThrow(() => view.getFloat32(7, false), RangeError);
view = new DataView(buffer4_r_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, false), RangeError);
checkThrow(() => view.getFloat32(10, false), RangeError);
// testFloatGet expected=NaN
// Little endian
view = new DataView(buffer5, 3, 1);
checkThrow(function () view.getFloat32(0, true), RangeError);
checkThrow(() => view.getFloat32(0, true), RangeError);
view = new DataView(buffer5_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, true), RangeError);
checkThrow(() => view.getFloat32(3, true), RangeError);
view = new DataView(buffer5_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, true), RangeError);
checkThrow(() => view.getFloat32(7, true), RangeError);
view = new DataView(buffer5_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, true), RangeError);
checkThrow(() => view.getFloat32(10, true), RangeError);
// Big endian.
view = new DataView(buffer5_r, 3, 1);
checkThrow(function () view.getFloat32(0, false), RangeError);
checkThrow(() => view.getFloat32(0, false), RangeError);
view = new DataView(buffer5_r_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, false), RangeError);
checkThrow(() => view.getFloat32(3, false), RangeError);
view = new DataView(buffer5_r_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, false), RangeError);
checkThrow(() => view.getFloat32(7, false), RangeError);
view = new DataView(buffer5_r_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, false), RangeError);
checkThrow(() => view.getFloat32(10, false), RangeError);
// testFloatGet expected=NaN
// Little endian
view = new DataView(buffer6, 3, 1);
checkThrow(function () view.getFloat32(0, true), RangeError);
checkThrow(() => view.getFloat32(0, true), RangeError);
view = new DataView(buffer6_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, true), RangeError);
checkThrow(() => view.getFloat32(3, true), RangeError);
view = new DataView(buffer6_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, true), RangeError);
checkThrow(() => view.getFloat32(7, true), RangeError);
view = new DataView(buffer6_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, true), RangeError);
checkThrow(() => view.getFloat32(10, true), RangeError);
// Big endian.
view = new DataView(buffer6_r, 3, 1);
checkThrow(function () view.getFloat32(0, false), RangeError);
checkThrow(() => view.getFloat32(0, false), RangeError);
view = new DataView(buffer6_r_pad3, 3, 4);
checkThrow(function () view.getFloat32(3, false), RangeError);
checkThrow(() => view.getFloat32(3, false), RangeError);
view = new DataView(buffer6_r_pad7, 3, 8);
checkThrow(function () view.getFloat32(7, false), RangeError);
checkThrow(() => view.getFloat32(7, false), RangeError);
view = new DataView(buffer6_r_pad10, 3, 11);
checkThrow(function () view.getFloat32(10, false), RangeError);
checkThrow(() => view.getFloat32(10, false), RangeError);
// testFloatGet expected=10
// Little endian
view = new DataView(buffer7, 3, 5);
checkThrow(function () view.getFloat64(0, true), RangeError);
checkThrow(() => view.getFloat64(0, true), RangeError);
view = new DataView(buffer7_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, true), RangeError);
checkThrow(() => view.getFloat64(3, true), RangeError);
view = new DataView(buffer7_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, true), RangeError);
checkThrow(() => view.getFloat64(7, true), RangeError);
view = new DataView(buffer7_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, true), RangeError);
checkThrow(() => view.getFloat64(10, true), RangeError);
// Big endian.
view = new DataView(buffer7_r, 3, 5);
checkThrow(function () view.getFloat64(0, false), RangeError);
checkThrow(() => view.getFloat64(0, false), RangeError);
view = new DataView(buffer7_r_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, false), RangeError);
checkThrow(() => view.getFloat64(3, false), RangeError);
view = new DataView(buffer7_r_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, false), RangeError);
checkThrow(() => view.getFloat64(7, false), RangeError);
view = new DataView(buffer7_r_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, false), RangeError);
checkThrow(() => view.getFloat64(10, false), RangeError);
// testFloatGet expected=1.23
// Little endian
view = new DataView(buffer8, 3, 5);
checkThrow(function () view.getFloat64(0, true), RangeError);
checkThrow(() => view.getFloat64(0, true), RangeError);
view = new DataView(buffer8_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, true), RangeError);
checkThrow(() => view.getFloat64(3, true), RangeError);
view = new DataView(buffer8_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, true), RangeError);
checkThrow(() => view.getFloat64(7, true), RangeError);
view = new DataView(buffer8_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, true), RangeError);
checkThrow(() => view.getFloat64(10, true), RangeError);
// Big endian.
view = new DataView(buffer8_r, 3, 5);
checkThrow(function () view.getFloat64(0, false), RangeError);
checkThrow(() => view.getFloat64(0, false), RangeError);
view = new DataView(buffer8_r_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, false), RangeError);
checkThrow(() => view.getFloat64(3, false), RangeError);
view = new DataView(buffer8_r_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, false), RangeError);
checkThrow(() => view.getFloat64(7, false), RangeError);
view = new DataView(buffer8_r_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, false), RangeError);
checkThrow(() => view.getFloat64(10, false), RangeError);
// testFloatGet expected=-6213576.4839
// Little endian
view = new DataView(buffer9, 3, 5);
checkThrow(function () view.getFloat64(0, true), RangeError);
checkThrow(() => view.getFloat64(0, true), RangeError);
view = new DataView(buffer9_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, true), RangeError);
checkThrow(() => view.getFloat64(3, true), RangeError);
view = new DataView(buffer9_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, true), RangeError);
checkThrow(() => view.getFloat64(7, true), RangeError);
view = new DataView(buffer9_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, true), RangeError);
checkThrow(() => view.getFloat64(10, true), RangeError);
// Big endian.
view = new DataView(buffer9_r, 3, 5);
checkThrow(function () view.getFloat64(0, false), RangeError);
checkThrow(() => view.getFloat64(0, false), RangeError);
view = new DataView(buffer9_r_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, false), RangeError);
checkThrow(() => view.getFloat64(3, false), RangeError);
view = new DataView(buffer9_r_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, false), RangeError);
checkThrow(() => view.getFloat64(7, false), RangeError);
view = new DataView(buffer9_r_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, false), RangeError);
checkThrow(() => view.getFloat64(10, false), RangeError);
// testFloatGet expected=NaN
// Little endian
view = new DataView(buffer10, 3, 5);
checkThrow(function () view.getFloat64(0, true), RangeError);
checkThrow(() => view.getFloat64(0, true), RangeError);
view = new DataView(buffer10_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, true), RangeError);
checkThrow(() => view.getFloat64(3, true), RangeError);
view = new DataView(buffer10_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, true), RangeError);
checkThrow(() => view.getFloat64(7, true), RangeError);
view = new DataView(buffer10_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, true), RangeError);
checkThrow(() => view.getFloat64(10, true), RangeError);
// Big endian.
view = new DataView(buffer10_r, 3, 5);
checkThrow(function () view.getFloat64(0, false), RangeError);
checkThrow(() => view.getFloat64(0, false), RangeError);
view = new DataView(buffer10_r_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, false), RangeError);
checkThrow(() => view.getFloat64(3, false), RangeError);
view = new DataView(buffer10_r_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, false), RangeError);
checkThrow(() => view.getFloat64(7, false), RangeError);
view = new DataView(buffer10_r_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, false), RangeError);
checkThrow(() => view.getFloat64(10, false), RangeError);
// testFloatGet expected=NaN
// Little endian
view = new DataView(buffer11, 3, 5);
checkThrow(function () view.getFloat64(0, true), RangeError);
checkThrow(() => view.getFloat64(0, true), RangeError);
view = new DataView(buffer11_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, true), RangeError);
checkThrow(() => view.getFloat64(3, true), RangeError);
view = new DataView(buffer11_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, true), RangeError);
checkThrow(() => view.getFloat64(7, true), RangeError);
view = new DataView(buffer11_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, true), RangeError);
checkThrow(() => view.getFloat64(10, true), RangeError);
// Big endian.
view = new DataView(buffer11_r, 3, 5);
checkThrow(function () view.getFloat64(0, false), RangeError);
checkThrow(() => view.getFloat64(0, false), RangeError);
view = new DataView(buffer11_r_pad3, 3, 8);
checkThrow(function () view.getFloat64(3, false), RangeError);
checkThrow(() => view.getFloat64(3, false), RangeError);
view = new DataView(buffer11_r_pad7, 3, 12);
checkThrow(function () view.getFloat64(7, false), RangeError);
checkThrow(() => view.getFloat64(7, false), RangeError);
view = new DataView(buffer11_r_pad10, 3, 15);
checkThrow(function () view.getFloat64(10, false), RangeError);
checkThrow(() => view.getFloat64(10, false), RangeError);
// testGetNegativeIndexes
view = new DataView(buffer1, 0, 16);
checkThrow(function () view.getInt8(-1), RangeError);
checkThrow(function () view.getInt8(-2), RangeError);
checkThrow(function () view.getUint8(-1), RangeError);
checkThrow(function () view.getUint8(-2), RangeError);
checkThrow(function () view.getInt16(-1), RangeError);
checkThrow(function () view.getInt16(-2), RangeError);
checkThrow(function () view.getInt16(-3), RangeError);
checkThrow(function () view.getUint16(-1), RangeError);
checkThrow(function () view.getUint16(-2), RangeError);
checkThrow(function () view.getUint16(-3), RangeError);
checkThrow(function () view.getInt32(-1), RangeError);
checkThrow(function () view.getInt32(-3), RangeError);
checkThrow(function () view.getInt32(-5), RangeError);
checkThrow(function () view.getUint32(-1), RangeError);
checkThrow(function () view.getUint32(-3), RangeError);
checkThrow(function () view.getUint32(-5), RangeError);
checkThrow(() => view.getInt8(-1), RangeError);
checkThrow(() => view.getInt8(-2), RangeError);
checkThrow(() => view.getUint8(-1), RangeError);
checkThrow(() => view.getUint8(-2), RangeError);
checkThrow(() => view.getInt16(-1), RangeError);
checkThrow(() => view.getInt16(-2), RangeError);
checkThrow(() => view.getInt16(-3), RangeError);
checkThrow(() => view.getUint16(-1), RangeError);
checkThrow(() => view.getUint16(-2), RangeError);
checkThrow(() => view.getUint16(-3), RangeError);
checkThrow(() => view.getInt32(-1), RangeError);
checkThrow(() => view.getInt32(-3), RangeError);
checkThrow(() => view.getInt32(-5), RangeError);
checkThrow(() => view.getUint32(-1), RangeError);
checkThrow(() => view.getUint32(-3), RangeError);
checkThrow(() => view.getUint32(-5), RangeError);
view = new DataView(buffer7, 0, 8);
checkThrow(function () view.getFloat32(-1), RangeError);
checkThrow(function () view.getFloat32(-3), RangeError);
checkThrow(function () view.getFloat32(-5), RangeError);
checkThrow(function () view.getFloat64(-1), RangeError);
checkThrow(function () view.getFloat64(-5), RangeError);
checkThrow(function () view.getFloat64(-9), RangeError);
checkThrow(() => view.getFloat32(-1), RangeError);
checkThrow(() => view.getFloat32(-3), RangeError);
checkThrow(() => view.getFloat32(-5), RangeError);
checkThrow(() => view.getFloat64(-1), RangeError);
checkThrow(() => view.getFloat64(-5), RangeError);
checkThrow(() => view.getFloat64(-9), RangeError);
// Too large for signed 32 bit integer index
checkThrow(function () view.getInt8(2147483648), RangeError);
checkThrow(function () view.getInt8(2147483649), RangeError);
checkThrow(function () view.getUint8(2147483648), RangeError);
checkThrow(function () view.getUint8(2147483649), RangeError);
checkThrow(function () view.getInt16(2147483648), RangeError);
checkThrow(function () view.getInt16(2147483649), RangeError);
checkThrow(function () view.getUint16(2147483648), RangeError);
checkThrow(function () view.getUint16(2147483649), RangeError);
checkThrow(function () view.getInt32(2147483648), RangeError);
checkThrow(function () view.getInt32(2147483649), RangeError);
checkThrow(function () view.getUint32(2147483648), RangeError);
checkThrow(function () view.getUint32(2147483649), RangeError);
checkThrow(function () view.getFloat32(2147483648), RangeError);
checkThrow(function () view.getFloat32(2147483649), RangeError);
checkThrow(function () view.getFloat64(2147483648), RangeError);
checkThrow(function () view.getFloat64(2147483649), RangeError);
checkThrow(() => view.getInt8(2147483648), RangeError);
checkThrow(() => view.getInt8(2147483649), RangeError);
checkThrow(() => view.getUint8(2147483648), RangeError);
checkThrow(() => view.getUint8(2147483649), RangeError);
checkThrow(() => view.getInt16(2147483648), RangeError);
checkThrow(() => view.getInt16(2147483649), RangeError);
checkThrow(() => view.getUint16(2147483648), RangeError);
checkThrow(() => view.getUint16(2147483649), RangeError);
checkThrow(() => view.getInt32(2147483648), RangeError);
checkThrow(() => view.getInt32(2147483649), RangeError);
checkThrow(() => view.getUint32(2147483648), RangeError);
checkThrow(() => view.getUint32(2147483649), RangeError);
checkThrow(() => view.getFloat32(2147483648), RangeError);
checkThrow(() => view.getFloat32(2147483649), RangeError);
checkThrow(() => view.getFloat64(2147483648), RangeError);
checkThrow(() => view.getFloat64(2147483649), RangeError);
// Test for wrong arguments passed to get methods
//
// See http://www.w3.org/TR/WebIDL/#es-operations and the step saying "If entry is null, throw a TypeError."
checkThrow(function () view.getInt8(), TypeError);
checkThrow(function () view.getUint8(), TypeError);
checkThrow(function () view.getInt16(), TypeError);
checkThrow(function () view.getUint16(), TypeError);
checkThrow(function () view.getInt32(), TypeError);
checkThrow(function () view.getUint32(), TypeError);
checkThrow(function () view.getFloat32(), TypeError);
checkThrow(function () view.getFloat64(), TypeError);
checkThrow(() => view.getInt8(), TypeError);
checkThrow(() => view.getUint8(), TypeError);
checkThrow(() => view.getInt16(), TypeError);
checkThrow(() => view.getUint16(), TypeError);
checkThrow(() => view.getInt32(), TypeError);
checkThrow(() => view.getUint32(), TypeError);
checkThrow(() => view.getFloat32(), TypeError);
checkThrow(() => view.getFloat64(), TypeError);
// Test for wrong type of |this|
checkThrow(function () view.getInt8.apply("dead", [0]), TypeError);
checkThrow(function () view.getUint8.apply("puppies", [0]), TypeError);
checkThrow(function () view.getInt16.apply("aren", [0]), TypeError);
checkThrow(function () view.getUint16.apply("t", [0]), TypeError);
checkThrow(function () view.getInt32.apply("much", [0]), TypeError);
checkThrow(function () view.getUint32.apply("fun", [0]), TypeError);
checkThrow(function () view.getFloat32.apply("(in", [0]), TypeError);
checkThrow(function () view.getFloat64.apply("bed)", [0]), TypeError);
checkThrow(function () view.setInt8.apply("dead", [0, 0]), TypeError);
checkThrow(function () view.setUint8.apply("puppies", [0, 0]), TypeError);
checkThrow(function () view.setInt16.apply("aren", [0, 0]), TypeError);
checkThrow(function () view.setUint16.apply("t", [0, 0]), TypeError);
checkThrow(function () view.setInt32.apply("much", [0, 0]), TypeError);
checkThrow(function () view.setUint32.apply("fun", [0, 0]), TypeError);
checkThrow(function () view.setFloat32.apply("(in", [0, 0]), TypeError);
checkThrow(function () view.setFloat64.apply("bed)", [0, 0]), TypeError);
checkThrow(() => view.getInt8.apply("dead", [0]), TypeError);
checkThrow(() => view.getUint8.apply("puppies", [0]), TypeError);
checkThrow(() => view.getInt16.apply("aren", [0]), TypeError);
checkThrow(() => view.getUint16.apply("t", [0]), TypeError);
checkThrow(() => view.getInt32.apply("much", [0]), TypeError);
checkThrow(() => view.getUint32.apply("fun", [0]), TypeError);
checkThrow(() => view.getFloat32.apply("(in", [0]), TypeError);
checkThrow(() => view.getFloat64.apply("bed)", [0]), TypeError);
checkThrow(() => view.setInt8.apply("dead", [0, 0]), TypeError);
checkThrow(() => view.setUint8.apply("puppies", [0, 0]), TypeError);
checkThrow(() => view.setInt16.apply("aren", [0, 0]), TypeError);
checkThrow(() => view.setUint16.apply("t", [0, 0]), TypeError);
checkThrow(() => view.setInt32.apply("much", [0, 0]), TypeError);
checkThrow(() => view.setUint32.apply("fun", [0, 0]), TypeError);
checkThrow(() => view.setFloat32.apply("(in", [0, 0]), TypeError);
checkThrow(() => view.setFloat64.apply("bed)", [0, 0]), TypeError);
// testSetMethods
@ -1146,52 +1146,52 @@ function test() {
view = new DataView(buffer13, 3, 2);
view.setInt8(0, 0);
assertEq(view.getInt8(0), 0);
checkThrow(function () view.setInt8(8, -128), RangeError);
checkThrow(function () view.setInt8(15, -1), RangeError);
checkThrow(() => view.setInt8(8, -128), RangeError);
checkThrow(() => view.setInt8(15, -1), RangeError);
view.setUint8(0, 0);
assertEq(view.getUint8(0), 0);
checkThrow(function () view.setUint8(8, 128), RangeError);
checkThrow(function () view.setUint8(15, 255), RangeError);
checkThrow(() => view.setUint8(8, 128), RangeError);
checkThrow(() => view.setUint8(15, 255), RangeError);
view.setInt16(0, 256, true);
assertEq(view.getInt16(0, true), 256);
checkThrow(function () view.setInt16(5, 26213, true), RangeError);
checkThrow(function () view.setInt16(9, -32127, true), RangeError);
checkThrow(function () view.setInt16(14, -2, true), RangeError);
checkThrow(() => view.setInt16(5, 26213, true), RangeError);
checkThrow(() => view.setInt16(9, -32127, true), RangeError);
checkThrow(() => view.setInt16(14, -2, true), RangeError);
view.setInt16(0, 1);
assertEq(view.getInt16(0), 1);
checkThrow(function () view.setInt16(5, 25958), RangeError);
checkThrow(function () view.setInt16(9, -32382), RangeError);
checkThrow(function () view.setInt16(14, -257), RangeError);
checkThrow(() => view.setInt16(5, 25958), RangeError);
checkThrow(() => view.setInt16(9, -32382), RangeError);
checkThrow(() => view.setInt16(14, -257), RangeError);
view.setUint16(0, 256, true);
assertEq(view.getUint16(0, true), 256);
checkThrow(function () view.setUint16(5, 26213, true), RangeError);
checkThrow(function () view.setUint16(9, 33409, true), RangeError);
checkThrow(function () view.setUint16(14, 65534, true), RangeError);
checkThrow(() => view.setUint16(5, 26213, true), RangeError);
checkThrow(() => view.setUint16(9, 33409, true), RangeError);
checkThrow(() => view.setUint16(14, 65534, true), RangeError);
view.setUint16(0, 1);
assertEq(view.getUint16(0), 1);
checkThrow(function () view.setUint16(5, 25958), RangeError);
checkThrow(function () view.setUint16(9, 33154), RangeError);
checkThrow(function () view.setUint16(14, 65279), RangeError);
checkThrow(function () view.setInt32(0, 50462976, true), RangeError);
checkThrow(function () view.setInt32(3, 1717920771, true), RangeError);
checkThrow(function () view.setInt32(6, -2122291354, true), RangeError);
checkThrow(function () view.setInt32(9, -58490239, true), RangeError);
checkThrow(function () view.setInt32(12, -66052, true), RangeError);
checkThrow(function () view.setInt32(0, 66051), RangeError);
checkThrow(function () view.setInt32(3, 56911206), RangeError);
checkThrow(function () view.setInt32(6, 1718059137), RangeError);
checkThrow(function () view.setInt32(9, -2122152964), RangeError);
checkThrow(function () view.setInt32(12, -50462977), RangeError);
checkThrow(function () view.setUint32(0, 50462976, true), RangeError);
checkThrow(function () view.setUint32(3, 1717920771, true), RangeError);
checkThrow(function () view.setUint32(6, 2172675942, true), RangeError);
checkThrow(function () view.setUint32(9, 4236477057, true), RangeError);
checkThrow(function () view.setUint32(12, 4294901244, true), RangeError);
checkThrow(function () view.setUint32(0, 66051), RangeError);
checkThrow(function () view.setUint32(3, 56911206), RangeError);
checkThrow(function () view.setUint32(6, 1718059137), RangeError);
checkThrow(function () view.setUint32(9, 2172814332), RangeError);
checkThrow(function () view.setUint32(12, 4244504319), RangeError);
checkThrow(() => view.setUint16(5, 25958), RangeError);
checkThrow(() => view.setUint16(9, 33154), RangeError);
checkThrow(() => view.setUint16(14, 65279), RangeError);
checkThrow(() => view.setInt32(0, 50462976, true), RangeError);
checkThrow(() => view.setInt32(3, 1717920771, true), RangeError);
checkThrow(() => view.setInt32(6, -2122291354, true), RangeError);
checkThrow(() => view.setInt32(9, -58490239, true), RangeError);
checkThrow(() => view.setInt32(12, -66052, true), RangeError);
checkThrow(() => view.setInt32(0, 66051), RangeError);
checkThrow(() => view.setInt32(3, 56911206), RangeError);
checkThrow(() => view.setInt32(6, 1718059137), RangeError);
checkThrow(() => view.setInt32(9, -2122152964), RangeError);
checkThrow(() => view.setInt32(12, -50462977), RangeError);
checkThrow(() => view.setUint32(0, 50462976, true), RangeError);
checkThrow(() => view.setUint32(3, 1717920771, true), RangeError);
checkThrow(() => view.setUint32(6, 2172675942, true), RangeError);
checkThrow(() => view.setUint32(9, 4236477057, true), RangeError);
checkThrow(() => view.setUint32(12, 4294901244, true), RangeError);
checkThrow(() => view.setUint32(0, 66051), RangeError);
checkThrow(() => view.setUint32(3, 56911206), RangeError);
checkThrow(() => view.setUint32(6, 1718059137), RangeError);
checkThrow(() => view.setUint32(9, 2172814332), RangeError);
checkThrow(() => view.setUint32(12, 4244504319), RangeError);
// testFloatSets(start=7)
@ -1479,57 +1479,57 @@ function test() {
// testSetNegativeIndexes
view = new DataView(buffer1, 0, 16);
checkThrow(function () view.setInt8(-1, 0), RangeError);
checkThrow(function () view.setInt8(-2, 0), RangeError);
checkThrow(function () view.setUint8(-1, 0), RangeError);
checkThrow(function () view.setUint8(-2, 0), RangeError);
checkThrow(function () view.setInt16(-1, 0), RangeError);
checkThrow(function () view.setInt16(-2, 0), RangeError);
checkThrow(function () view.setInt16(-3, 0), RangeError);
checkThrow(function () view.setUint16(-1, 0), RangeError);
checkThrow(function () view.setUint16(-2, 0), RangeError);
checkThrow(function () view.setUint16(-3, 0), RangeError);
checkThrow(function () view.setInt32(-1, 0), RangeError);
checkThrow(function () view.setInt32(-3, 0), RangeError);
checkThrow(function () view.setInt32(-5, 0), RangeError);
checkThrow(function () view.setUint32(-1, 0), RangeError);
checkThrow(function () view.setUint32(-3, 0), RangeError);
checkThrow(function () view.setUint32(-5, 0), RangeError);
checkThrow(() => view.setInt8(-1, 0), RangeError);
checkThrow(() => view.setInt8(-2, 0), RangeError);
checkThrow(() => view.setUint8(-1, 0), RangeError);
checkThrow(() => view.setUint8(-2, 0), RangeError);
checkThrow(() => view.setInt16(-1, 0), RangeError);
checkThrow(() => view.setInt16(-2, 0), RangeError);
checkThrow(() => view.setInt16(-3, 0), RangeError);
checkThrow(() => view.setUint16(-1, 0), RangeError);
checkThrow(() => view.setUint16(-2, 0), RangeError);
checkThrow(() => view.setUint16(-3, 0), RangeError);
checkThrow(() => view.setInt32(-1, 0), RangeError);
checkThrow(() => view.setInt32(-3, 0), RangeError);
checkThrow(() => view.setInt32(-5, 0), RangeError);
checkThrow(() => view.setUint32(-1, 0), RangeError);
checkThrow(() => view.setUint32(-3, 0), RangeError);
checkThrow(() => view.setUint32(-5, 0), RangeError);
view = new DataView(buffer7, 0, 8);
checkThrow(function () view.setFloat32(-1, 0), RangeError);
checkThrow(function () view.setFloat32(-3, 0), RangeError);
checkThrow(function () view.setFloat32(-5, 0), RangeError);
checkThrow(function () view.setFloat64(-1, 0), RangeError);
checkThrow(function () view.setFloat64(-5, 0), RangeError);
checkThrow(function () view.setFloat64(-9, 0), RangeError);
checkThrow(() => view.setFloat32(-1, 0), RangeError);
checkThrow(() => view.setFloat32(-3, 0), RangeError);
checkThrow(() => view.setFloat32(-5, 0), RangeError);
checkThrow(() => view.setFloat64(-1, 0), RangeError);
checkThrow(() => view.setFloat64(-5, 0), RangeError);
checkThrow(() => view.setFloat64(-9, 0), RangeError);
// Too large for signed 32 bit integer index
checkThrow(function () view.setInt8(2147483649, 1), RangeError);
checkThrow(function () view.setUint8(2147483649, 1), RangeError);
checkThrow(function () view.setInt16(2147483649, 1), RangeError);
checkThrow(function () view.setUint16(2147483649, 1), RangeError);
checkThrow(function () view.setInt32(2147483649, 1), RangeError);
checkThrow(function () view.setUint32(2147483649, 1), RangeError);
checkThrow(function () view.setFloat32(2147483649, 1), RangeError);
checkThrow(function () view.setFloat64(2147483649, 1), RangeError);
checkThrow(() => view.setInt8(2147483649, 1), RangeError);
checkThrow(() => view.setUint8(2147483649, 1), RangeError);
checkThrow(() => view.setInt16(2147483649, 1), RangeError);
checkThrow(() => view.setUint16(2147483649, 1), RangeError);
checkThrow(() => view.setInt32(2147483649, 1), RangeError);
checkThrow(() => view.setUint32(2147483649, 1), RangeError);
checkThrow(() => view.setFloat32(2147483649, 1), RangeError);
checkThrow(() => view.setFloat64(2147483649, 1), RangeError);
// Test for wrong arguments passed to set methods
checkThrow(function () view.setInt8(), Error);
checkThrow(function () view.setUint8(), Error);
checkThrow(function () view.setInt16(), Error);
checkThrow(function () view.setUint16(), Error);
checkThrow(function () view.setInt32(), Error);
checkThrow(function () view.setUint32(), Error);
checkThrow(function () view.setFloat32(), Error);
checkThrow(function () view.setFloat64(), Error);
checkThrow(function () view.setInt8(1), Error);
checkThrow(function () view.setUint8(1), Error);
checkThrow(function () view.setInt16(1), Error);
checkThrow(function () view.setUint16(1), Error);
checkThrow(function () view.setInt32(1), Error);
checkThrow(function () view.setUint32(1), Error);
checkThrow(function () view.setFloat32(1), Error);
checkThrow(function () view.setFloat64(1), Error);
checkThrow(() => view.setInt8(), Error);
checkThrow(() => view.setUint8(), Error);
checkThrow(() => view.setInt16(), Error);
checkThrow(() => view.setUint16(), Error);
checkThrow(() => view.setInt32(), Error);
checkThrow(() => view.setUint32(), Error);
checkThrow(() => view.setFloat32(), Error);
checkThrow(() => view.setFloat64(), Error);
checkThrow(() => view.setInt8(1), Error);
checkThrow(() => view.setUint8(1), Error);
checkThrow(() => view.setInt16(1), Error);
checkThrow(() => view.setUint16(1), Error);
checkThrow(() => view.setInt32(1), Error);
checkThrow(() => view.setUint32(1), Error);
checkThrow(() => view.setFloat32(1), Error);
checkThrow(() => view.setFloat64(1), Error);
// testAlignment
var intArray1 = [0, 1, 2, 3, 100, 101, 102, 103, 128, 129, 130, 131, 252, 253, 254, 255];
@ -1582,9 +1582,9 @@ function test() {
}, TypeError);
// Accessing DataView fields on DataView.prototype should crash
checkThrow(function () DataView.prototype.byteLength, TypeError);
checkThrow(function () DataView.prototype.byteOffset, TypeError);
checkThrow(function () DataView.prototype.buffer, TypeError);
checkThrow(() => DataView.prototype.byteLength, TypeError);
checkThrow(() => DataView.prototype.byteOffset, TypeError);
checkThrow(() => DataView.prototype.buffer, TypeError);
// Protos and proxies, oh my!
var alien = newGlobal();
@ -1594,10 +1594,10 @@ function test() {
// proto is view of buffer: should throw
var o = Object.create(view1);
checkThrow(function () o.getUint8(4), TypeError); // WebIDL 4.4.7: Operations
checkThrow(function () o.buffer, TypeError); // WebIDL 4.4.6: Attributes, section 2
checkThrow(function () o.byteOffset, TypeError);
checkThrow(function () o.byteLength, TypeError);
checkThrow(() => o.getUint8(4), TypeError); // WebIDL 4.4.7: Operations
checkThrow(() => o.buffer, TypeError); // WebIDL 4.4.6: Attributes, section 2
checkThrow(() => o.byteOffset, TypeError);
checkThrow(() => o.byteLength, TypeError);
// proxy for view of buffer: should work
assertEq(alien_view.buffer.byteLength > 0, true);
@ -1629,8 +1629,8 @@ function test() {
// TypeError, and in fact it throws a (thisglobal).TypeError instead of
// alien.TypeError.
var av = Object.create(alien_view);
checkThrowTODO(function () av.getUint8(4), alien.TypeError);
checkThrowTODO(function () av.buffer, alien.TypeError);
checkThrowTODO(() => av.getUint8(4), alien.TypeError);
checkThrowTODO(() => av.buffer, alien.TypeError);
// view of object whose proto is buffer. This should not work per dherman.
// Note that DataView throws a TypeError while TypedArrays create a
@ -1639,7 +1639,7 @@ function test() {
// TypedArray will do ToUint32 and end up passing a zero as the
// constructor's length argument.
buffer = Object.create(buffer1);
checkThrow(function () new DataView(buffer), TypeError);
checkThrow(() => new DataView(buffer), TypeError);
// view of proxy for buffer
av = new DataView(alien_buffer);

View File

@ -82,14 +82,14 @@ function test()
if (typeof(type) !== 'undefined')
if (thrown) {
check(function () thrown instanceof type,
check(() => thrown instanceof type,
"expected " + type.name + " but saw " + thrown,
todo);
} else {
check(function () thrown, "expected " + type.name + " but no exception thrown", todo);
check(() => thrown, "expected " + type.name + " but no exception thrown", todo);
}
else
check(function () thrown, undefined, todo);
check(() => thrown, undefined, todo);
}
function checkThrowsTODO(fun, type) {
@ -209,118 +209,118 @@ function test()
var buf, buf2;
buf = new ArrayBuffer(100);
check(function() buf);
check(function() buf.byteLength == 100);
check(() => buf);
check(() => buf.byteLength == 100);
buf.byteLength = 50;
check(function() buf.byteLength == 100);
check(() => buf.byteLength == 100);
var zerobuf = new ArrayBuffer(0);
check(function() zerobuf);
check(function() zerobuf.byteLength == 0);
check(() => zerobuf);
check(() => zerobuf.byteLength == 0);
check(function() (new Int32Array(zerobuf)).length == 0);
checkThrows(function() new Int32Array(zerobuf, 1));
check(() => (new Int32Array(zerobuf)).length == 0);
checkThrows(() => new Int32Array(zerobuf, 1));
var zerobuf2 = new ArrayBuffer();
check(function() zerobuf2.byteLength == 0);
check(() => zerobuf2.byteLength == 0);
checkThrows(function() new ArrayBuffer(-100), RangeError);
checkThrows(() => new ArrayBuffer(-100), RangeError);
// this is using js_ValueToECMAUInt32, which is giving 0 for "abc"
checkThrowsTODO(function() new ArrayBuffer("abc"), TypeError);
checkThrowsTODO(() => new ArrayBuffer("abc"), TypeError);
var zeroarray = new Int32Array(0);
check(function() zeroarray.length == 0);
check(function() zeroarray.byteLength == 0);
check(function() zeroarray.buffer);
check(function() zeroarray.buffer.byteLength == 0);
check(() => zeroarray.length == 0);
check(() => zeroarray.byteLength == 0);
check(() => zeroarray.buffer);
check(() => zeroarray.buffer.byteLength == 0);
var zeroarray2 = new Int32Array();
check(function() zeroarray2.length == 0);
check(function() zeroarray2.byteLength == 0);
check(function() zeroarray2.buffer);
check(function() zeroarray2.buffer.byteLength == 0);
check(() => zeroarray2.length == 0);
check(() => zeroarray2.byteLength == 0);
check(() => zeroarray2.buffer);
check(() => zeroarray2.buffer.byteLength == 0);
var a = new Int32Array(20);
check(function() a);
check(function() a.length == 20);
check(function() a.byteLength == 80);
check(function() a.byteOffset == 0);
check(function() a.buffer);
check(function() a.buffer.byteLength == 80);
check(() => a);
check(() => a.length == 20);
check(() => a.byteLength == 80);
check(() => a.byteOffset == 0);
check(() => a.buffer);
check(() => a.buffer.byteLength == 80);
var b = new Uint8Array(a.buffer, 4, 4);
check(function() b);
check(function() b.length == 4);
check(function() b.byteLength == 4);
check(function() a.buffer == b.buffer);
check(() => b);
check(() => b.length == 4);
check(() => b.byteLength == 4);
check(() => a.buffer == b.buffer);
b[0] = 0xaa;
b[1] = 0xbb;
b[2] = 0xcc;
b[3] = 0xdd;
check(function() a[0] == 0);
check(function() a[1] != 0);
check(function() a[2] == 0);
check(() => a[0] == 0);
check(() => a[1] != 0);
check(() => a[2] == 0);
buf = new ArrayBuffer(4);
check(function() (new Int8Array(buf)).length == 4);
check(function() (new Uint8Array(buf)).length == 4);
check(function() (new Int16Array(buf)).length == 2);
check(function() (new Uint16Array(buf)).length == 2);
check(function() (new Int32Array(buf)).length == 1);
check(function() (new Uint32Array(buf)).length == 1);
check(function() (new Float32Array(buf)).length == 1);
checkThrows(function() (new Float64Array(buf)));
check(() => (new Int8Array(buf)).length == 4);
check(() => (new Uint8Array(buf)).length == 4);
check(() => (new Int16Array(buf)).length == 2);
check(() => (new Uint16Array(buf)).length == 2);
check(() => (new Int32Array(buf)).length == 1);
check(() => (new Uint32Array(buf)).length == 1);
check(() => (new Float32Array(buf)).length == 1);
checkThrows(() => (new Float64Array(buf)));
buf2 = new ArrayBuffer(8);
check(function() (new Float64Array(buf2)).length == 1);
check(() => (new Float64Array(buf2)).length == 1);
buf = new ArrayBuffer(5);
check(function() buf);
check(function() buf.byteLength == 5);
check(() => buf);
check(() => buf.byteLength == 5);
check(function() new Int32Array(buf, 0, 1));
checkThrows(function() new Int32Array(buf, 0));
check(function() new Int8Array(buf, 0));
check(() => new Int32Array(buf, 0, 1));
checkThrows(() => new Int32Array(buf, 0));
check(() => new Int8Array(buf, 0));
check(function() (new Int8Array(buf, 3)).byteLength == 2);
checkThrows(function() new Int8Array(buf, 500));
checkThrows(function() new Int8Array(buf, 0, 50));
checkThrows(function() new Float32Array(buf, 500));
checkThrows(function() new Float32Array(buf, 0, 50));
check(() => (new Int8Array(buf, 3)).byteLength == 2);
checkThrows(() => new Int8Array(buf, 500));
checkThrows(() => new Int8Array(buf, 0, 50));
checkThrows(() => new Float32Array(buf, 500));
checkThrows(() => new Float32Array(buf, 0, 50));
var sl = a.subarray(5,10);
check(function() sl.length == 5);
check(function() sl.buffer == a.buffer);
check(function() sl.byteLength == 20);
check(function() sl.byteOffset == 20);
check(() => sl.length == 5);
check(() => sl.buffer == a.buffer);
check(() => sl.byteLength == 20);
check(() => sl.byteOffset == 20);
check(function() a.subarray(5,5).length == 0);
check(function() a.subarray(-5).length == 5);
check(function() a.subarray(-100).length == 20);
check(function() a.subarray(0, 2).length == 2);
check(function() a.subarray().length == a.length);
check(function() a.subarray(-7,-5).length == 2);
check(function() a.subarray(-5,-7).length == 0);
check(function() a.subarray(15).length == 5);
check(() => a.subarray(5,5).length == 0);
check(() => a.subarray(-5).length == 5);
check(() => a.subarray(-100).length == 20);
check(() => a.subarray(0, 2).length == 2);
check(() => a.subarray().length == a.length);
check(() => a.subarray(-7,-5).length == 2);
check(() => a.subarray(-5,-7).length == 0);
check(() => a.subarray(15).length == 5);
a = new Uint8Array([0xaa, 0xbb, 0xcc]);
check(function() a.length == 3);
check(function() a.byteLength == 3);
check(function() a[1] == 0xbb);
check(() => a.length == 3);
check(() => a.byteLength == 3);
check(() => a[1] == 0xbb);
// not sure if this is supposed to throw or to treat "foo"" as 0.
checkThrowsTODO(function() new Int32Array([0xaa, "foo", 0xbb]), Error);
checkThrowsTODO(() => new Int32Array([0xaa, "foo", 0xbb]), Error);
checkThrows(function() new Int32Array(-100));
checkThrows(() => new Int32Array(-100));
a = new Uint8Array(3);
// XXX these are ignored now and return undefined
//checkThrows(function() a[5000] = 0, RangeError);
//checkThrows(function() a["hello"] = 0, TypeError);
//checkThrows(function() a[-10] = 0, RangeError);
check(function() (a[0] = "10") && (a[0] == 10));
//checkThrows(() => a[5000] = 0, RangeError);
//checkThrows(() => a["hello"] = 0, TypeError);
//checkThrows(() => a[-10] = 0, RangeError);
check(() => (a[0] = "10") && (a[0] == 10));
// check Uint8ClampedArray, which is an extension to this extension
a = new Uint8ClampedArray(4);
@ -329,10 +329,10 @@ function test()
a[2] = -123.723;
a[3] = "foopy";
check(function() a[0] == 128);
check(function() a[1] == 255);
check(function() a[2] == 0);
check(function() a[3] == 0);
check(() => a[0] == 128);
check(() => a[1] == 255);
check(() => a[2] == 0);
check(() => a[3] == 0);
// check handling of holes and non-numeric values
var x = Array(5);
@ -343,18 +343,18 @@ function test()
x[4] = true;
a = new Uint8Array(x);
check(function() a[0] == 0);
check(function() a[1] == 0);
check(function() a[2] == 0);
check(function() a[3] == 0);
check(function() a[4] == 1);
check(() => a[0] == 0);
check(() => a[1] == 0);
check(() => a[2] == 0);
check(() => a[3] == 0);
check(() => a[4] == 1);
a = new Float32Array(x);
check(function() !(a[0] == a[0]));
check(function() !(a[1] == a[1]));
check(function() !(a[2] == a[2]));
check(function() !(a[3] == a[3]));
check(function() a[4] == 1);
check(() => !(a[0] == a[0]));
check(() => !(a[1] == a[1]));
check(() => !(a[2] == a[2]));
check(() => !(a[3] == a[3]));
check(() => a[4] == 1);
// test set()
var empty = new Int32Array(0);
@ -364,9 +364,9 @@ function test()
empty.set([], 0);
empty.set(empty);
checkThrows(function() empty.set([1]));
checkThrows(function() empty.set([1], 0));
checkThrows(function() empty.set([1], 1));
checkThrows(() => empty.set([1]));
checkThrows(() => empty.set([1], 0));
checkThrows(() => empty.set([1], 1));
a.set([]);
a.set([], 3);
@ -377,24 +377,24 @@ function test()
a.set(empty, 3);
a.set(empty, 9);
a.set(Array.prototype);
checkThrows(function() a.set(empty, 100));
checkThrows(() => a.set(empty, 100));
checkThrows(function() a.set([1,2,3,4,5,6,7,8,9,10]));
checkThrows(function() a.set([1,2,3,4,5,6,7,8,9,10], 0));
checkThrows(function() a.set([1,2,3,4,5,6,7,8,9,10], 0x7fffffff));
checkThrows(function() a.set([1,2,3,4,5,6,7,8,9,10], 0xffffffff));
checkThrows(function() a.set([1,2,3,4,5,6], 6));
checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10]));
checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10], 0));
checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10], 0x7fffffff));
checkThrows(() => a.set([1,2,3,4,5,6,7,8,9,10], 0xffffffff));
checkThrows(() => a.set([1,2,3,4,5,6], 6));
checkThrows(function() a.set(new Array(0x7fffffff)));
checkThrows(function() a.set([1,2,3], 2147483647));
checkThrows(() => a.set(new Array(0x7fffffff)));
checkThrows(() => a.set([1,2,3], 2147483647));
a.set(ArrayBuffer.prototype);
checkThrows(function () a.set(Int16Array.prototype), TypeError);
checkThrows(function () a.set(Int32Array.prototype), TypeError);
checkThrows(() => a.set(Int16Array.prototype), TypeError);
checkThrows(() => a.set(Int32Array.prototype), TypeError);
a.set([1,2,3]);
a.set([4,5,6], 3);
check(function()
check(() =>
a[0] == 1 && a[1] == 2 && a[2] == 3 &&
a[3] == 4 && a[4] == 5 && a[5] == 6 &&
a[6] == 0 && a[7] == 0 && a[8] == 0);
@ -402,25 +402,25 @@ function test()
b = new Float32Array([7,8,9]);
a.set(b, 0);
a.set(b, 3);
check(function()
check(() =>
a[0] == 7 && a[1] == 8 && a[2] == 9 &&
a[3] == 7 && a[4] == 8 && a[5] == 9 &&
a[6] == 0 && a[7] == 0 && a[8] == 0);
a.set(a.subarray(0,3), 6);
check(function()
check(() =>
a[0] == 7 && a[1] == 8 && a[2] == 9 &&
a[3] == 7 && a[4] == 8 && a[5] == 9 &&
a[6] == 7 && a[7] == 8 && a[8] == 9);
a.set([1,2,3,4,5,6,7,8,9]);
a.set(a.subarray(0,6), 3);
check(function()
check(() =>
a[0] == 1 && a[1] == 2 && a[2] == 3 &&
a[3] == 1 && a[4] == 2 && a[5] == 3 &&
a[6] == 4 && a[7] == 5 && a[8] == 6);
a.set(a.subarray(3,9), 0);
check(function()
check(() =>
a[0] == 1 && a[1] == 2 && a[2] == 3 &&
a[3] == 4 && a[4] == 5 && a[5] == 6 &&
a[6] == 4 && a[7] == 5 && a[8] == 6);
@ -428,15 +428,15 @@ function test()
// verify that subarray() returns a new view that
// references the same buffer
a.subarray(0,3).set(a.subarray(3,6), 0);
check(function()
check(() =>
a[0] == 4 && a[1] == 5 && a[2] == 6 &&
a[3] == 4 && a[4] == 5 && a[5] == 6 &&
a[6] == 4 && a[7] == 5 && a[8] == 6);
a = new ArrayBuffer(0x10);
checkThrows(function() new Uint32Array(buffer, 4, 0x3FFFFFFF));
checkThrows(() => new Uint32Array(buffer, 4, 0x3FFFFFFF));
checkThrows(function() new Float32Array(null));
checkThrows(() => new Float32Array(null));
a = new Uint8Array(0x100);
b = Uint32Array.prototype.subarray.apply(a, [0, 0x100]);
@ -450,29 +450,29 @@ function test()
// webidl section 4.4.6, getter bullet point 2.2: prototypes are not
// platform objects, and calling the getter of any attribute defined on the
// interface should throw a TypeError according to
checkThrows(function() ArrayBuffer.prototype.byteLength, TypeError);
checkThrows(function() Int32Array.prototype.length, TypeError);
checkThrows(function() Int32Array.prototype.byteLength, TypeError);
checkThrows(function() Int32Array.prototype.byteOffset, TypeError);
checkThrows(function() Float64Array.prototype.length, TypeError);
checkThrows(function() Float64Array.prototype.byteLength, TypeError);
checkThrows(function() Float64Array.prototype.byteOffset, TypeError);
checkThrows(() => ArrayBuffer.prototype.byteLength, TypeError);
checkThrows(() => Int32Array.prototype.length, TypeError);
checkThrows(() => Int32Array.prototype.byteLength, TypeError);
checkThrows(() => Int32Array.prototype.byteOffset, TypeError);
checkThrows(() => Float64Array.prototype.length, TypeError);
checkThrows(() => Float64Array.prototype.byteLength, TypeError);
checkThrows(() => Float64Array.prototype.byteOffset, TypeError);
// webidl 4.4.6: a readonly attribute's setter is undefined. From
// observation, that seems to mean it silently does nothing, and returns
// the value that you tried to set it to.
check(function() Int32Array.prototype.length = true);
check(function() Float64Array.prototype.length = true);
check(function() Int32Array.prototype.byteLength = true);
check(function() Float64Array.prototype.byteLength = true);
check(function() Int32Array.prototype.byteOffset = true);
check(function() Float64Array.prototype.byteOffset = true);
check(() => Int32Array.prototype.length = true);
check(() => Float64Array.prototype.length = true);
check(() => Int32Array.prototype.byteLength = true);
check(() => Float64Array.prototype.byteLength = true);
check(() => Int32Array.prototype.byteOffset = true);
check(() => Float64Array.prototype.byteOffset = true);
// ArrayBuffer, Int32Array and Float64Array are native functions and have a
// .length, so none of these should throw:
check(function() (new Int32Array(ArrayBuffer)).length >= 0);
check(function() (new Int32Array(Int32Array)).length >= 0);
check(function() (new Int32Array(Float64Array)).length >= 0);
check(() => (new Int32Array(ArrayBuffer)).length >= 0);
check(() => (new Int32Array(Int32Array)).length >= 0);
check(() => (new Int32Array(Float64Array)).length >= 0);
// webidl 4.4.6, under getters: "The value of the Function objects
// 'length' property is the Number value 0"
@ -485,24 +485,24 @@ function test()
//
//check(Object.getOwnPropertyDescriptor(Int32Array.prototype, 'byteOffset')['get'].length == 0);
check(function() Int32Array.BYTES_PER_ELEMENT == 4);
check(function() (new Int32Array(4)).BYTES_PER_ELEMENT == 4);
check(function() (new Int32Array()).BYTES_PER_ELEMENT == 4);
check(function() (new Int32Array(0)).BYTES_PER_ELEMENT == 4);
check(function() Int16Array.BYTES_PER_ELEMENT == Uint16Array.BYTES_PER_ELEMENT);
check(() => Int32Array.BYTES_PER_ELEMENT == 4);
check(() => (new Int32Array(4)).BYTES_PER_ELEMENT == 4);
check(() => (new Int32Array()).BYTES_PER_ELEMENT == 4);
check(() => (new Int32Array(0)).BYTES_PER_ELEMENT == 4);
check(() => Int16Array.BYTES_PER_ELEMENT == Uint16Array.BYTES_PER_ELEMENT);
// test various types of args; Math.sqrt(4) is used to ensure that the
// function gets a double, and not a demoted int
check(function() (new Float32Array(Math.sqrt(4))).length == 2);
check(function() (new Float32Array({ length: 10 })).length == 10);
check(function() (new Float32Array({})).length == 0);
checkThrows(function() new Float32Array("3"));
checkThrows(function() new Float32Array(null));
checkThrows(function() new Float32Array(undefined));
check(() => (new Float32Array(Math.sqrt(4))).length == 2);
check(() => (new Float32Array({ length: 10 })).length == 10);
check(() => (new Float32Array({})).length == 0);
checkThrows(() => new Float32Array("3"));
checkThrows(() => new Float32Array(null));
checkThrows(() => new Float32Array(undefined));
// check that NaN conversions happen correctly with array conversions
check(function() (new Int32Array([NaN])[0]) == 0);
check(function() { var q = new Float32Array([NaN])[0]; return q != q; });
check(() => (new Int32Array([NaN])[0]) == 0);
check(() => { var q = new Float32Array([NaN])[0]; return q != q; });
// check that setting and reading arbitrary properties works
// this is not something that will be done in real world
@ -510,29 +510,29 @@ function test()
// regular objects
buf = new ArrayBuffer(128);
a = new Uint32Array(buf, 0, 4);
check(function() a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0);
check(() => a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0);
buf.a = 42;
buf.b = "abcdefgh";
buf.c = {a:'literal'};
check(function() a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0);
check(() => a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0);
check(function() buf.a == 42);
check(() => buf.a == 42);
delete buf.a;
check(function() !buf.a);
check(() => !buf.a);
// check edge cases for small arrays
// 16 reserved slots
a = new Uint8Array(120);
check(function() a.byteLength == 120);
check(function() a.length == 120);
check(() => a.byteLength == 120);
check(() => a.length == 120);
for (var i = 0; i < a.length; i++)
check(function() a[i] == 0)
check(() => a[i] == 0)
a = new Uint8Array(121);
check(function() a.byteLength == 121);
check(function() a.length == 121);
check(() => a.byteLength == 121);
check(() => a.length == 121);
for (var i = 0; i < a.length; i++)
check(function() a[i] == 0)
check(() => a[i] == 0)
// check that TM generated byte offset is right (requires run with -j)
a = new Uint8Array(100);
@ -540,7 +540,7 @@ function test()
b = new Uint8Array(a.buffer, 9); // force a offset
// use a loop to invoke the TM
for (var i = 0; i < b.length; i++)
check(function() b[90] == 5)
check(() => b[90] == 5)
// Protos and proxies, oh my!
var alien = newGlobal();
@ -556,22 +556,22 @@ function test()
// First make sure they're looking at the same data
alien_view[3] = 77;
check(function () view[3] == 77);
check(() => view[3] == 77);
// Now check that the proxy setup is as expected
check(function () isProxy(alien_view));
check(function () isProxy(alien_buffer));
check(function () isProxy(view)); // the real test
check(() => isProxy(alien_view));
check(() => isProxy(alien_buffer));
check(() => isProxy(view)); // the real test
// cross-compartment property access
check(function () alien_buffer.byteLength == 7);
check(function () alien_view.byteLength == 7);
check(function () view.byteLength == 7);
check(() => alien_buffer.byteLength == 7);
check(() => alien_view.byteLength == 7);
check(() => view.byteLength == 7);
// typed array protos should be equal
simple = new Int8Array(12);
check(function () Object.getPrototypeOf(view) == Object.getPrototypeOf(simple));
check(function () Object.getPrototypeOf(view) == Int8Array.prototype);
check(() => Object.getPrototypeOf(view) == Object.getPrototypeOf(simple));
check(() => Object.getPrototypeOf(view) == Int8Array.prototype);
// Most named properties are defined on %TypedArray%.prototype.
check(() => !simple.hasOwnProperty('byteLength'));
@ -586,10 +586,10 @@ function test()
// But we are currently discussing the situation, and typed arrays may be
// pulled into the ES spec, so for now this is disallowed.
if (false) {
check(function () simple.byteLength == 12);
check(() => simple.byteLength == 12);
getter = Object.getOwnPropertyDescriptor(Int8Array.prototype, 'byteLength').get;
Object.defineProperty(Int8Array.prototype, 'byteLength', { get: function () { return 1 + getter.apply(this) } });
check(function () simple.byteLength == 13);
check(() => simple.byteLength == 13);
}
// test copyWithin()
@ -603,7 +603,7 @@ function test()
var numbers_buffer = new Uint8Array(numbers).buffer;
var view = new Int8Array(numbers_buffer, offset);
view.copyWithin(dest, start, end);
check(function () tastring(view) == want.toString());
check(() => tastring(view) == want.toString());
if (tastring(view) != want.toString()) {
print("Wanted: " + want.toString());
print("Got : " + tastring(view));

View File

@ -76,45 +76,45 @@ function test()
thrown = true;
}
check(function() thrown, todo);
check(() => thrown, todo);
}
var key = {};
var map = new WeakMap();
check(function() !map.has(key));
check(function() map.delete(key) == false);
check(function() map.set(key, 42) === map);
check(function() map.get(key) == 42);
check(function() typeof map.get({}) == "undefined");
check(function() map.get({}, "foo") == undefined);
check(() => !map.has(key));
check(() => map.delete(key) == false);
check(() => map.set(key, 42) === map);
check(() => map.get(key) == 42);
check(() => typeof map.get({}) == "undefined");
check(() => map.get({}, "foo") == undefined);
gc(); gc(); gc();
check(function() map.get(key) == 42);
check(function() map.delete(key) == true);
check(function() map.delete(key) == false);
check(function() map.delete({}) == false);
check(() => map.get(key) == 42);
check(() => map.delete(key) == true);
check(() => map.delete(key) == false);
check(() => map.delete({}) == false);
check(function() typeof map.get(key) == "undefined");
check(function() !map.has(key));
check(function() map.delete(key) == false);
check(() => typeof map.get(key) == "undefined");
check(() => !map.has(key));
check(() => map.delete(key) == false);
var value = { };
check(function() map.set(new Object(), value) === map);
check(() => map.set(new Object(), value) === map);
gc(); gc(); gc();
check(function() map.has("non-object key") == false);
check(function() map.has() == false);
check(function() map.get("non-object key") == undefined);
check(function() map.get() == undefined);
check(function() map.delete("non-object key") == false);
check(function() map.delete() == false);
check(() => map.has("non-object key") == false);
check(() => map.has() == false);
check(() => map.get("non-object key") == undefined);
check(() => map.get() == undefined);
check(() => map.delete("non-object key") == false);
check(() => map.delete() == false);
check(function() map.set(key) === map);
check(function() map.get(key) == undefined);
check(() => map.set(key) === map);
check(() => map.get(key) == undefined);
checkThrows(function() map.set("non-object key", value));
checkThrows(() => map.set("non-object key", value));
print ("done");