use hex literals

This commit is contained in:
Robin Templeton 2017-10-24 11:48:34 -04:00
parent 2892cc78c7
commit f2322cf8a6
4 changed files with 80 additions and 80 deletions

View File

@ -36,33 +36,33 @@ features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt]
var buffer = new ArrayBuffer(16);
var sample = new DataView(buffer, 0);
sample.setUint8(0, 39);
sample.setUint8(1, 2);
sample.setUint8(2, 6);
sample.setUint8(3, 2);
sample.setUint8(4, 128);
sample.setUint8(5, 0);
sample.setUint8(6, 128);
sample.setUint8(7, 1);
sample.setUint8(8, 127);
sample.setUint8(9, 0);
sample.setUint8(10, 1);
sample.setUint8(11, 2);
sample.setUint8(12, 128);
sample.setUint8(13, 127);
sample.setUint8(14, 255);
sample.setUint8(15, 128);
sample.setUint8(0, 0x27);
sample.setUint8(1, 0x02);
sample.setUint8(2, 0x06);
sample.setUint8(3, 0x02);
sample.setUint8(4, 0x80);
sample.setUint8(5, 0x00);
sample.setUint8(6, 0x80);
sample.setUint8(7, 0x01);
sample.setUint8(8, 0x7f);
sample.setUint8(9, 0x00);
sample.setUint8(10, 0x01);
sample.setUint8(11, 0x02);
sample.setUint8(12, 0x80);
sample.setUint8(13, 0x7f);
sample.setUint8(14, 0xff);
sample.setUint8(15, 0x80);
sample = new DataView(buffer, 4);
assert.sameValue(sample.getBigInt64(0, false), -9223231292940746494n, "0, false");
assert.sameValue(sample.getBigInt64(1, false) , 36030441991504512n, "1, false");
assert.sameValue(sample.getBigInt64(2, false) , -9222950923884396417n, "2, false");
assert.sameValue(sample.getBigInt64(3, false) , 107804920417124351n, "3, false");
assert.sameValue(sample.getBigInt64(4, false) , 9151315553074282368n, "4, false");
assert.sameValue(sample.getBigInt64(0, false), -0x7fff7ffe80fffefen, "0, false");
assert.sameValue(sample.getBigInt64(1, false), 0x80017f00010280n, "1, false");
assert.sameValue(sample.getBigInt64(2, false), -0x7ffe80fffefd7f81n, "2, false");
assert.sameValue(sample.getBigInt64(3, false), 0x17f000102807fffn, "3, false");
assert.sameValue(sample.getBigInt64(4, false), 0x7f000102807fff80n, "4, false");
assert.sameValue(sample.getBigInt64(0, true) , 144397208538579072n, "0, true");
assert.sameValue(sample.getBigInt64(1, true) , -9222807985258921984n, "1, true");
assert.sameValue(sample.getBigInt64(2, true) , 9187345443162358144n, "2, true");
assert.sameValue(sample.getBigInt64(3, true) , -36169525900574975n, "3, true");
assert.sameValue(sample.getBigInt64(4, true) , -9151455730027396993n, "4, true");
assert.sameValue(sample.getBigInt64(0, true), 0x201007f01800080n, "0, true");
assert.sameValue(sample.getBigInt64(1, true), -0x7ffdfeff80fe8000n, "1, true");
assert.sameValue(sample.getBigInt64(2, true), 0x7f800201007f0180n, "2, true");
assert.sameValue(sample.getBigInt64(3, true), -0x807ffdfeff80ffn, "3, true");
assert.sameValue(sample.getBigInt64(4, true), -0x7f00807ffdfeff81n, "4, true");

View File

@ -31,39 +31,39 @@ features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt]
var buffer = new ArrayBuffer(16);
var sample = new DataView(buffer, 0);
sample.setUint8(0, 39);
sample.setUint8(1, 2);
sample.setUint8(2, 6);
sample.setUint8(3, 2);
sample.setUint8(4, 128);
sample.setUint8(5, 0);
sample.setUint8(6, 128);
sample.setUint8(7, 1);
sample.setUint8(8, 127);
sample.setUint8(9, 0);
sample.setUint8(10, 1);
sample.setUint8(11, 2);
sample.setUint8(12, 128);
sample.setUint8(13, 127);
sample.setUint8(14, 255);
sample.setUint8(15, 128);
sample.setUint8(0, 0x27);
sample.setUint8(1, 0x02);
sample.setUint8(2, 0x06);
sample.setUint8(3, 0x02);
sample.setUint8(4, 0x80);
sample.setUint8(5, 0x00);
sample.setUint8(6, 0x80);
sample.setUint8(7, 0x01);
sample.setUint8(8, 0x7f);
sample.setUint8(9, 0x00);
sample.setUint8(10, 0x01);
sample.setUint8(11, 0x02);
sample.setUint8(12, 0x80);
sample.setUint8(13, 0x7f);
sample.setUint8(14, 0xff);
sample.setUint8(15, 0x80);
assert.sameValue(sample.getBigInt64(0, false), 2810815725239828481n, "0, false");
assert.sameValue(sample.getBigInt64(1, false), 145806786723578239n, "1, false");
assert.sameValue(sample.getBigInt64(2, false), 433049253816925952n, "2, false");
assert.sameValue(sample.getBigInt64(3, false), 180144534875734017n, "3, false");
assert.sameValue(sample.getBigInt64(4, false), -9223231292940746494n, "4, false");
assert.sameValue(sample.getBigInt64(5, false), 36030441991504512n, "5, false");
assert.sameValue(sample.getBigInt64(6, false), -9222950923884396417n, "6, false");
assert.sameValue(sample.getBigInt64(7, false), 107804920417124351n, "7, false");
assert.sameValue(sample.getBigInt64(8, false), 9151315553074282368n, "8, false");
assert.sameValue(sample.getBigInt64(0, false), 0x2702060280008001n, "0, false");
assert.sameValue(sample.getBigInt64(1, false), 0x20602800080017fn, "1, false");
assert.sameValue(sample.getBigInt64(2, false), 0x602800080017f00n, "2, false");
assert.sameValue(sample.getBigInt64(3, false), 0x2800080017f0001n, "3, false");
assert.sameValue(sample.getBigInt64(4, false), -0x7fff7ffe80fffefen, "4, false");
assert.sameValue(sample.getBigInt64(5, false), 0x80017f00010280n, "5, false");
assert.sameValue(sample.getBigInt64(6, false), -0x7ffe80fffefd7f81n, "6, false");
assert.sameValue(sample.getBigInt64(7, false), 0x17f000102807fffn, "7, false");
assert.sameValue(sample.getBigInt64(8, false), 0x7f000102807fff80n, "8, false");
assert.sameValue(sample.getBigInt64(0, true), 108086940846653991n, "0, true");
assert.sameValue(sample.getBigInt64(1, true), 9151736657429530114n, "1, true");
assert.sameValue(sample.getBigInt64(2, true), 35748971318084102n, "2, true");
assert.sameValue(sample.getBigInt64(3, true), 72197238457139202n, "3, true");
assert.sameValue(sample.getBigInt64(4, true), 144397208538579072n, "4, true");
assert.sameValue(sample.getBigInt64(5, true), -9222807985258921984n, "5, true");
assert.sameValue(sample.getBigInt64(6, true), 9187345443162358144n, "6, true");
assert.sameValue(sample.getBigInt64(7, true), -36169525900574975n, "7, true");
assert.sameValue(sample.getBigInt64(8, true), -9151455730027396993n, "8, true");
assert.sameValue(sample.getBigInt64(0, true), 0x180008002060227n, "0, true");
assert.sameValue(sample.getBigInt64(1, true), 0x7f01800080020602n, "1, true");
assert.sameValue(sample.getBigInt64(2, true), 0x7f018000800206n, "2, true");
assert.sameValue(sample.getBigInt64(3, true), 0x1007f0180008002n, "3, true");
assert.sameValue(sample.getBigInt64(4, true), 0x201007f01800080n, "4, true");
assert.sameValue(sample.getBigInt64(5, true), -0x7ffdfeff80fe8000n, "5, true");
assert.sameValue(sample.getBigInt64(6, true), 0x7f800201007f0180n, "6, true");
assert.sameValue(sample.getBigInt64(7, true), -0x807ffdfeff80ffn, "7, true");
assert.sameValue(sample.getBigInt64(8, true), -0x7f00807ffdfeff81n, "8, true");

View File

@ -39,15 +39,15 @@ features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt, Symbol, S
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
sample.setUint8(7, 255);
sample.setUint8(7, 0xff);
// False
assert.sameValue(sample.getBigInt64(0), 255n, "no argument");
assert.sameValue(sample.getBigInt64(0), 0xffn, "no argument");
testCoercibleToBooleanFalse(function (x) {
assert.sameValue(sample.getBigInt64(0, x), 255n);
assert.sameValue(sample.getBigInt64(0, x), 0xffn);
});
// True
testCoercibleToBooleanTrue(function (x) {
assert.sameValue(sample.getBigInt64(0, x), -72057594037927936n);
assert.sameValue(sample.getBigInt64(0, x), -0x100000000000000n);
});

View File

@ -24,31 +24,31 @@ features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt, Symbol, S
var buffer = new ArrayBuffer(12);
var sample = new DataView(buffer, 0);
sample.setUint8(0, 39);
sample.setUint8(1, 2);
sample.setUint8(2, 6);
sample.setUint8(3, 2);
sample.setUint8(4, 128);
sample.setUint8(5, 0);
sample.setUint8(6, 128);
sample.setUint8(7, 1);
sample.setUint8(8, 127);
sample.setUint8(9, 0);
sample.setUint8(10, 1);
sample.setUint8(11, 2);
sample.setUint8(0, 0x27);
sample.setUint8(1, 0x02);
sample.setUint8(2, 0x06);
sample.setUint8(3, 0x02);
sample.setUint8(4, 0x80);
sample.setUint8(5, 0x00);
sample.setUint8(6, 0x80);
sample.setUint8(7, 0x01);
sample.setUint8(8, 0x7f);
sample.setUint8(9, 0x00);
sample.setUint8(10, 0x01);
sample.setUint8(11, 0x02);
testCoercibleToIndexZero(function (x) {
assert.sameValue(sample.getBigInt64(x), 2810815725239828481n);
assert.sameValue(sample.getBigInt64(x), 0x2702060280008001n);
});
testCoercibleToIndexOne(function (x) {
assert.sameValue(sample.getBigInt64(x), 145806786723578239n);
assert.sameValue(sample.getBigInt64(x), 0x20602800080017fn);
});
testCoercibleToIndexFromIndex(2, function (x) {
assert.sameValue(sample.getBigInt64(x), 433049253816925952n);
assert.sameValue(sample.getBigInt64(x), 0x602800080017F00n);
});
testCoercibleToIndexFromIndex(3, function (x) {
assert.sameValue(sample.getBigInt64(x), 180144534875734017n);
assert.sameValue(sample.getBigInt64(x), 0x2800080017F0001n);
});