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

test: basic functionality of readUIntLE() #10359

Closed
wants to merge 1 commit into from

Conversation

larissayvette
Copy link
Contributor

@larissayvette larissayvette commented Dec 20, 2016

Checklist
  • commit message follows commit guidelines
Affected core subsystem(s)

test

Description of change

test readUIntLE() when noAsset is tfalse and when it is false

@nodejs-github-bot nodejs-github-bot added test Issues and PRs related to the tests. lts-watch-v6.x labels Dec 20, 2016
@mscdex mscdex added the buffer Issues and PRs related to the buffer subsystem. label Dec 20, 2016
@julianduque
Copy link
Contributor

Copy link
Member

@Trott Trott left a 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);
Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor Author

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);},
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here.

@julianduque
Copy link
Contributor

assert.strictEqual(result, 168);

assert.throws(
() => { buf.readUIntLE(5); }, RangeError);
Copy link
Member

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);

Copy link
Member

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); },
Copy link
Member

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.

@Trott
Copy link
Member

Trott commented Dec 22, 2016

@cjihrig This PR has been updated to address your comments. Can you take a look and, if appropriate, update your review?

@larissayvette
Copy link
Contributor Author

@Trott I modified the linting as you said

@Trott
Copy link
Member

Trott commented Dec 22, 2016

assert.strictEqual(result, 168);

assert.throws(
() => {
Copy link
Member

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...

Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

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/
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok thanks @jasnell

Copy link
Member

@Trott Trott Dec 23, 2016

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$/
)

@larissayvette
Copy link
Contributor Author

@jasnell I made the changes

@jasnell
Copy link
Member

jasnell commented Dec 23, 2016 via email

@jasnell
Copy link
Member

jasnell commented Dec 24, 2016

@cjihrig ... ping .. does this LGTY now?

@jasnell
Copy link
Member

jasnell commented Dec 24, 2016

@Trott
Copy link
Member

Trott commented Dec 24, 2016

Previous CI run seems to have terminated oddly. Let's try again...

CI: https://ci.nodejs.org/job/node-test-pull-request/5579/

@Trott
Copy link
Member

Trott commented Dec 24, 2016

(Failure on arm-fanned is CI infrastructure related and not a result of these changes.)

Trott pushed a commit to Trott/io.js that referenced this pull request Dec 24, 2016
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]>
@Trott
Copy link
Member

Trott commented Dec 24, 2016

Landed in 66c0767

@Trott Trott closed this Dec 24, 2016
@Trott
Copy link
Member

Trott commented Dec 24, 2016

🎉

@larissayvette larissayvette deleted the test-buffer branch December 28, 2016 15:51
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
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]>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
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]>
MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
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]>
@MylesBorins
Copy link
Contributor

this is failing on v4.x, is that expected?

=== release test-buffer-readuintle ===
Path: parallel/test-buffer-readuintle
assert.js:354
    throw actual;
    ^

RangeError: index out of range
    at checkOffset (buffer.js:696:11)
    at Buffer.readUIntLE (buffer.js:704:5)
    at /Users/thealphanerd/code/node/v4.x/test/parallel/test-buffer-readuintle.js:14:9
    at _tryBlock (assert.js:313:5)
    at _throws (assert.js:332:12)
    at Function.assert.throws (assert.js:362:3)
    at Object.<anonymous> (/Users/thealphanerd/code/node/v4.x/test/parallel/test-buffer-readuintle.js:12:8)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
Command: out/Release/node /Users/thealphanerd/code/node/v4.x/test/parallel/test-buffer-readuintle.js

@Trott
Copy link
Member

Trott commented Jan 23, 2017

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.

MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
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]>
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2017
MylesBorins pushed a commit that referenced this pull request Jan 31, 2017
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants