Skip to content

Commit

Permalink
test for .into() fails
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Aug 9, 2010
1 parent 9721352 commit 5e7cdc0
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 0 deletions.
Empty file modified test/advance.js 100755 → 100644
Empty file.
Empty file modified test/binary.js 100755 → 100644
Empty file.
Empty file modified test/binary_assign.js 100755 → 100644
Empty file.
Empty file modified test/binary_endianness.js 100755 → 100644
Empty file.
Empty file modified test/binary_event.js 100755 → 100644
Empty file.
48 changes: 48 additions & 0 deletions test/binary_into.js
@@ -0,0 +1,48 @@
// Check .into(), especially for object pollution
var sys = require('sys');
var Buffer = require('buffer').Buffer;
var BufferList = require('bufferlist');
var Binary = require('bufferlist/binary');

exports.into = function (assert) {
var bList = new BufferList;
var tapped = false;

Binary(bList)
.getWord8('ones')
.into('frac', function () {
this
.getWord64be('64')
.getWord32be('32')
.getWord16be('16')
.getWord8('8')
})
.tap(function (vars) {
tapped = true;

assert.equal(vars.ones, 3);
assert.equal(vars.frac['64'], 73184615082362370);
assert.equal(vars.frac['32'], 50661385);
assert.equal(vars.frac['16'], 1801);
assert.equal(vars.frac['8'], 3);

assert.equal(
Object.keys(vars).sort().join(' '), 'frac ones',
'object pollution with .into()'
)
})
.end()
;

var buf = new Buffer(16);
var i = 0;
String(4 * Math.atan2(1,1)).split('').forEach(function (digit) {
if (digit != '.') {
buf[i++] = parseInt(digit,10);
}
});
bList.push(buf);

assert.ok(tapped, 'not tapped');
};

Empty file modified test/binary_jump.js 100755 → 100644
Empty file.
Empty file modified test/binary_loop.js 100755 → 100644
Empty file.
Empty file modified test/client_server.js 100755 → 100644
Empty file.
Empty file modified test/event.js 100755 → 100644
Empty file.
Empty file modified test/join.js 100755 → 100644
Empty file.

0 comments on commit 5e7cdc0

Please sign in to comment.