mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 17:10:40 +00:00

The assert.fail function signature has the message as the third argument but, understandably, it is often assumed that it is the first argument (or at least the first argument if no other arguments are passed). This corrects the assert.fail() invocations in the Node.js tests. Before: assert.fail('message'); // result: AssertionError: 'message' undefined undefined After: assert.fail(null, null, 'message'); // result: AssertionError: message PR-URL: https://github.com/nodejs/node/pull/3378 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
38 lines
734 B
JavaScript
38 lines
734 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var R = require('_stream_readable');
|
|
var W = require('_stream_writable');
|
|
var assert = require('assert');
|
|
|
|
var src = new R({encoding: 'base64'});
|
|
var dst = new W();
|
|
var hasRead = false;
|
|
var accum = [];
|
|
var timeout;
|
|
|
|
src._read = function(n) {
|
|
if (!hasRead) {
|
|
hasRead = true;
|
|
process.nextTick(function() {
|
|
src.push(new Buffer('1'));
|
|
src.push(null);
|
|
});
|
|
};
|
|
};
|
|
|
|
dst._write = function(chunk, enc, cb) {
|
|
accum.push(chunk);
|
|
cb();
|
|
};
|
|
|
|
src.on('end', function() {
|
|
assert.equal(Buffer.concat(accum) + '', 'MQ==');
|
|
clearTimeout(timeout);
|
|
});
|
|
|
|
src.pipe(dst);
|
|
|
|
timeout = setTimeout(function() {
|
|
assert.fail(null, null, 'timed out waiting for _write');
|
|
}, 100);
|