-
Notifications
You must be signed in to change notification settings - Fork 30k
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: refactor buffer tests #8256
Conversation
for (const size of sizes) { | ||
try { | ||
// These allocations are known to fail. If they do, | ||
// Uin32Array should still produce a zeroed out result. |
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.
typo: Uint32Array
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.
Fixed
a9e1407
to
d67bd34
Compare
LGTM. Thanks for keeping a lot of separate commits! |
var b = Buffer.allocUnsafe(1024); | ||
|
||
console.log('b.length == %d', b.length); | ||
const b = Buffer.allocUnsafe(1024); | ||
assert.strictEqual(1024, b.length); |
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.
The API for assert.strictEqual()
and friends indicates that the actual value received should be the first parameter and the expected value should be second but it's backwards here and below. Feel free to leave it as is (since this isn't code you wrote, it's just an adjacent line), but if you want to swap them, hey, go for it.
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.
(And yes, I'm going for the most useless nit I can imagine here. Like I said, feel free to ignore.)
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.
There are many places in the tests where they are in the wrong order. For now, I'm inclined to leave these as they are. It would be a good first contribution for someone tho :-)
Remove duplication of buffer tests, separate out into separate files, update and cleanup code, move to using strictEqual where possible. PR-URL: #8256 Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Landed in 7053922! |
Having lots of conflicts on this into v6. |
Remove duplication of buffer tests, separate out into separate files, update and cleanup code, move to using strictEqual where possible. PR-URL: nodejs#8256 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Conflicts: test/parallel/test-buffer-alloc.js test/parallel/test-buffer.js test/parallel/test-buffer-no-negative-allocation.js
Remove duplication of buffer tests, separate out into separate files, update and cleanup code, move to using strictEqual where possible. PR-URL: #8256 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Conflicts: test/parallel/test-buffer-alloc.js test/parallel/test-buffer.js test/parallel/test-buffer-no-negative-allocation.js
this is not landing on v4.x please feel free to backport |
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
buffer,test
Description of change
Refactor the Buffer tests, eliminate duplication, move certain tests out to the own test files, updated and modernize, prefer use of strictEqual where appropriate.