node/test/parallel/test-stream-push-order.js
Rich Trott a7335bd1f0 test,benchmark: use deepStrictEqual()
In preparation for a lint rule that will enforce
assert.deepStrictEqual() over assert.deepEqual(), change tests and
benchmarks accordingly. For tests and benchmarks that are testing or
benchmarking assert.deepEqual() itself, apply a comment to ignore the
upcoming rule.

PR-URL: https://github.com/nodejs/node/pull/6213
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-22 14:38:09 -07:00

33 lines
597 B
JavaScript

'use strict';
require('../common');
var Readable = require('stream').Readable;
var assert = require('assert');
var s = new Readable({
highWaterMark: 20,
encoding: 'ascii'
});
var list = ['1', '2', '3', '4', '5', '6'];
s._read = function(n) {
var one = list.shift();
if (!one) {
s.push(null);
} else {
var two = list.shift();
s.push(one);
s.push(two);
}
};
s.read(0);
// ACTUALLY [1, 3, 5, 6, 4, 2]
process.on('exit', function() {
assert.deepStrictEqual(s._readableState.buffer,
['1', '2', '3', '4', '5', '6']);
console.log('ok');
});