-
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: basic functionality of readUIntLE() #10359
Conversation
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.
LGTM. This provides coverage for a code branch that is not currently covered.
assert.strictEqual(result, 168); | ||
|
||
assert.throws( | ||
() => { buf.readUIntLE(5);}, RangeError); |
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.
Space between the ;
and }
please.
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.
This the type of thing that could and should be enforced via linting. So let's do that: #10377
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.
making the changes right away
() => { buf.readUIntLE(5);}, RangeError); | ||
|
||
assert.doesNotThrow( | ||
() => { assert.strictEqual(buf.readUIntLE(5, 0, true), undefined);}, |
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.
Same comment here.
0096611
to
4473247
Compare
assert.strictEqual(result, 168); | ||
|
||
assert.throws( | ||
() => { buf.readUIntLE(5); }, RangeError); |
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.
Any reason not to just make it all one line, like this?:
assert.throws(() => { buf.readIntLE(5); }, RangeError);
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.
Or, if you prefer to split it up for readability, please indent by only two lines and put the closing parenthesis on a separate line:
assert.throws(
() => { buf.readIntLE(5); }, RangeError
);
The indent-by-two-chars is something that should be caught by the linter but currently is not. I think it will start to be reported when we update our ESLint version. But there are a few obstacles to that at the moment.
() => { buf.readUIntLE(5); }, RangeError); | ||
|
||
assert.doesNotThrow( | ||
() => { assert.strictEqual(buf.readUIntLE(5, 0, true), undefined); }, |
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.
As mentioned above, if you could make this indented by just two characters, that would likely be preferable. Again, sorry our linter doesn't yet report that.
@cjihrig This PR has been updated to address your comments. Can you take a look and, if appropriate, update your review? |
4473247
to
284e552
Compare
@Trott I modified the linting as you said |
assert.strictEqual(result, 168); | ||
|
||
assert.throws( | ||
() => { |
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.
minor nit: the formatting on this does not match the regular style...
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.
@jasnell Can you be more specific? To my mind, this would be OK if the indentation on line 13 was two spaces rather than six spaces. Is that your opinion too?
assert.throws( | ||
() => { | ||
buf.readUIntLE(5); | ||
}, RangeError |
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.
Testing the error message would be more reliable here.
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.
@jasnell I do not get what you mean
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.
@larissayvette for example, doing a regex agains the error message thrown by RangeError in this case:
assert.throws(
() => {
buf.readUIntLE(5);
}, /Index out of range/
)
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.
ok thanks @jasnell
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.
I would take it a step further and match the entire message from beginning to end, since (currently) any change to an error message is considered a breaking change.
assert.throws(
() => {
buf.readUIntLE(5);
}, /^RangeError: Index out of range$/
)
284e552
to
e025941
Compare
@jasnell I made the changes |
e025941
to
258cc0e
Compare
Yes, that is what I meant with regards to indentation
…On Fri, Dec 23, 2016 at 9:09 AM Rich Trott ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In test/parallel/test-buffer-readuintle.js
<#10359>:
> @@ -0,0 +1,22 @@
+'use strict';
+require('../common');
+const assert = require('assert');
+
+// testing basic functionality of readUIntLE()
+
+const buf = Buffer.from([42, 84, 168, 127]);
+const result = buf.readUIntLE(2);
+
+assert.strictEqual(result, 168);
+
+assert.throws(
+ () => {
@jasnell <https://github.com/jasnell> Can you be more specific? To my
mind, this would be OK if the indentation on line 13 was two spaces rather
than six spaces. Is that your opinion too?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10359>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAa2eei4QelzhBaf0UHiAWEKXwGDZLbIks5rLAA-gaJpZM4LSOf_>
.
|
@cjihrig ... ping .. does this LGTY now? |
Previous CI run seems to have terminated oddly. Let's try again... |
(Failure on arm-fanned is CI infrastructure related and not a result of these changes.) |
PR-URL: nodejs#10359 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Landed in 66c0767 |
🎉 |
PR-URL: #10359 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #10359 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #10359 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
this is failing on v4.x, is that expected?
|
The error message changed between 4.x and 6.x. This test gets deleted by a subsequent PR anyway (already marked as do-not-land-on-v4.x) so I'll label this similarly. |
PR-URL: #10359 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #10359 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Checklist
Affected core subsystem(s)
test
Description of change
test readUIntLE() when noAsset is tfalse and when it is false