Skip to content
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

stream: remove unreachable code #18239

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: use correct size in test-stream-buffer-list
The `n` argument of `BufferList.prototype.concat()` is not the number
of `Buffer` instances in the list, but their total length when
concatenated.
lpinca committed Jan 18, 2018
commit 4461fa5fb94ccc722e1467150424a5bd301b3dc3
11 changes: 8 additions & 3 deletions test/parallel/test-stream-buffer-list.js
Original file line number Diff line number Diff line change
@@ -15,16 +15,21 @@ assert.strictEqual(emptyList.join(','), '');

assert.deepStrictEqual(emptyList.concat(0), Buffer.alloc(0));

const buf = Buffer.from('foo');

// Test buffer list with one element.
const list = new BufferList();
list.push('foo');
list.push(buf);

const copy = list.concat(3);

assert.strictEqual(list.concat(1), 'foo');
Copy link
Member Author

@lpinca lpinca Jan 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcollina this is wrong whether or not the change in BufferList.js is applied.

  • The test uses a string, probably for simplicity, but concat() only works with buffers.
  • The n argument (1) was wrong and irrelevant. You could have used any argument and the test would have still passed.

assert.notStrictEqual(copy, buf);
assert.deepStrictEqual(copy, buf);

assert.strictEqual(list.join(','), 'foo');

const shifted = list.shift();
assert.strictEqual(shifted, 'foo');
assert.strictEqual(shifted, buf);
assert.deepStrictEqual(list, new BufferList());

const tmp = util.inspect.defaultOptions.colors;