-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test revisions #10551
Test revisions #10551
Changes from 2 commits
a26d602
fd8fa5b
15a48bc
b550a8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
'use strict'; | ||
require('../common'); | ||
var assert = require('assert'); | ||
const assert = require('assert'); | ||
const Readable = require('_stream_readable'); | ||
const Writable = require('_stream_writable'); | ||
const EE = require('events').EventEmitter; | ||
|
||
var Readable = require('_stream_readable'); | ||
var Writable = require('_stream_writable'); | ||
var EE = require('events').EventEmitter; | ||
|
||
var testRuns = 0, completedRuns = 0; | ||
function runTest(highWaterMark, objectMode, produce) { | ||
testRuns++; | ||
|
||
var old = new EE(); | ||
var r = new Readable({ highWaterMark: highWaterMark, | ||
const old = new EE(); | ||
const r = new Readable({ highWaterMark: highWaterMark, | ||
objectMode: objectMode }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation needs to be adjusted here to re-align with the first 'h'. |
||
assert.equal(r, r.wrap(old)); | ||
assert.strictEqual(r, r.wrap(old)); | ||
|
||
var ended = false; | ||
r.on('end', function() { | ||
let ended = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed completely, along with any references since we're already ensuring 'end' is seen via |
||
r.on('end', common.mustCall(function() { | ||
ended = true; | ||
}); | ||
})); | ||
|
||
old.pause = function() { | ||
console.error('old.pause()'); | ||
|
@@ -32,14 +29,14 @@ function runTest(highWaterMark, objectMode, produce) { | |
flow(); | ||
}; | ||
|
||
var flowing; | ||
var chunks = 10; | ||
var oldEnded = false; | ||
var expected = []; | ||
let flowing; | ||
let chunks = 10; | ||
let oldEnded = false; | ||
const expected = []; | ||
function flow() { | ||
flowing = true; | ||
while (flowing && chunks-- > 0) { | ||
var item = produce(); | ||
const item = produce(); | ||
expected.push(item); | ||
console.log('old.emit', chunks, flowing); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove all of these |
||
old.emit('data', item); | ||
|
@@ -52,19 +49,18 @@ function runTest(highWaterMark, objectMode, produce) { | |
} | ||
} | ||
|
||
var w = new Writable({ highWaterMark: highWaterMark * 2, | ||
const w = new Writable({ highWaterMark: highWaterMark * 2, | ||
objectMode: objectMode }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation here needs to be adjusted as well. |
||
var written = []; | ||
const written = []; | ||
w._write = function(chunk, encoding, cb) { | ||
console.log('_write', chunk); | ||
written.push(chunk); | ||
setTimeout(cb); | ||
setTimeout(cb, 1000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
}; | ||
|
||
w.on('finish', function() { | ||
completedRuns++; | ||
w.on('finish', common.mustCall(function() { | ||
performAsserts(); | ||
}); | ||
})); | ||
|
||
r.pipe(w); | ||
|
||
|
@@ -77,14 +73,10 @@ function runTest(highWaterMark, objectMode, produce) { | |
} | ||
} | ||
|
||
runTest(100, false, function() { return Buffer.allocUnsafe(100); }); | ||
runTest(10, false, function() { return Buffer.from('xxxxxxxxxx'); }); | ||
runTest(1, true, function() { return { foo: 'bar' }; }); | ||
runTest(100, false, common.mustCall(function() { return Buffer.allocUnsafe(100); }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a missing |
||
runTest(10, false, common.mustCall(function() { return Buffer.from('xxxxxxxxxx'); })); | ||
runTest(1, true, common.mustCall(function() { return { foo: 'bar' }; })); | ||
|
||
var objectChunks = [ 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555 ]; | ||
runTest(1, true, function() { return objectChunks.shift(); }); | ||
const objectChunks = [ 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555 ]; | ||
runTest(1, true, common.mustCall(function() { return objectChunks.shift(); })); | ||
|
||
process.on('exit', function() { | ||
assert.equal(testRuns, completedRuns); | ||
console.log('ok'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common
is undefined because this line has not been changed toconst common = require('../common');
So again, there's no way this test can actually run as is.