node/test/parallel/test-stream2-compatibility.js
Gibson Fahnestock 3d2aef3979 test: s/assert.equal/assert.strictEqual/
Use assert.strictEqual instead of assert.equal in tests, manually
convert types where necessary.

PR-URL: https://github.com/nodejs/node/pull/10698
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2017-01-11 14:19:26 +00:00

53 lines
992 B
JavaScript

'use strict';
require('../common');
const R = require('_stream_readable');
const W = require('_stream_writable');
const assert = require('assert');
const util = require('util');
let ondataCalled = 0;
function TestReader() {
R.apply(this);
this._buffer = Buffer.alloc(100, 'x');
this.on('data', function() {
ondataCalled++;
});
}
util.inherits(TestReader, R);
TestReader.prototype._read = function(n) {
this.push(this._buffer);
this._buffer = Buffer.alloc(0);
};
const reader = new TestReader();
setImmediate(function() {
assert.strictEqual(ondataCalled, 1);
console.log('ok');
reader.push(null);
});
function TestWriter() {
W.apply(this);
this.write('foo');
this.end();
}
util.inherits(TestWriter, W);
TestWriter.prototype._write = function(chunk, enc, cb) {
cb();
};
const writer = new TestWriter();
process.on('exit', function() {
assert.strictEqual(reader.readable, false);
assert.strictEqual(writer.writable, false);
console.log('ok');
});