"fd", "fdff", "fffd", "fdffffff", "fffffffd"
];
var reads = [ 3, 3, 3, 3, 3, -3, -3, -3, -3, -3 ];
- ["UInt","Int"].forEach(function(x){
- [8,16,32].forEach(function(y){
- var endianesses = (y === 8) ? [""] : ["LE","BE"];
- endianesses.forEach(function(z){
- var v1 = new B(y / 8);
- var writefn = "write" + x + y + z;
- var val = (x === "Int") ? -3 : 3;
- v1[writefn](val, 0);
- t.equal(
- v1.toString("hex"),
- hex.shift()
- );
- var readfn = "read" + x + y + z;
- t.equal(
- v1[readfn](0),
- reads.shift()
- );
- });
- });
- });
+ var xs = ["UInt","Int"];
+ var ys = [8,16,32];
+ for (var i = 0; i < xs.length; i++) {
+ var x = xs[i];
+ for (var j = 0; j < ys.length; j++) {
+ var y = ys[j];
+ var endianesses = (y === 8) ? [""] : ["LE","BE"];
+ for (var k = 0; k < endianesses.length; k++) {
+ var z = endianesses[k];
+
+ var v1 = new B(y / 8);
+ var writefn = "write" + x + y + z;
+ var val = (x === "Int") ? -3 : 3;
+ v1[writefn](val, 0);
+ t.equal(
+ v1.toString("hex"),
+ hex.shift()
+ );
+ var readfn = "read" + x + y + z;
+ t.equal(
+ v1[readfn](0),
+ reads.shift()
+ );
+ }
+ }
+ }
t.end();
});
undefined, 3, 0, 3, 0,
undefined, 253, -256, 16777213, -256
];
- ["UInt","Int"].forEach(function(x){
- [8,16,32].forEach(function(y){
- var endianesses = (y === 8) ? [""] : ["LE","BE"];
- endianesses.forEach(function(z){
- var v1 = new B(y / 8 - 1);
- var next = new B(4);
- next.writeUInt32BE(0, 0);
- var writefn = "write" + x + y + z;
- var val = (x === "Int") ? -3 : 3;
- v1[writefn](val, 0, true);
- t.equal(
- v1.toString("hex"),
- hex.shift()
- );
- // check that nothing leaked to next buffer.
- t.equal(next.readUInt32BE(0), 0);
- // check that no bytes are read from next buffer.
- next.writeInt32BE(~0, 0);
- var readfn = "read" + x + y + z;
- t.equal(
- v1[readfn](0, true),
- reads.shift()
- );
- });
- });
- });
+ var xs = ["UInt","Int"];
+ var ys = [8,16,32];
+ for (var i = 0; i < xs.length; i++) {
+ var x = xs[i];
+ for (var j = 0; j < ys.length; j++) {
+ var y = ys[j];
+ var endianesses = (y === 8) ? [""] : ["LE","BE"];
+ for (var k = 0; k < endianesses.length; k++) {
+ var z = endianesses[k];
+
+ var v1 = new B(y / 8 - 1);
+ var next = new B(4);
+ next.writeUInt32BE(0, 0);
+ var writefn = "write" + x + y + z;
+ var val = (x === "Int") ? -3 : 3;
+ v1[writefn](val, 0, true);
+ t.equal(
+ v1.toString("hex"),
+ hex.shift()
+ );
+ // check that nothing leaked to next buffer.
+ t.equal(next.readUInt32BE(0), 0);
+ // check that no bytes are read from next buffer.
+ next.writeInt32BE(~0, 0);
+ var readfn = "read" + x + y + z;
+ t.equal(
+ v1[readfn](0, true),
+ reads.shift()
+ );
+ }
+ }
+ }
t.end();
});