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: check codes of thrown errors #23519

Closed

Conversation

truonghnancy
Copy link
Contributor

@truonghnancy truonghnancy commented Oct 12, 2018

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Oct 12, 2018
@jasnell jasnell added code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. and removed code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. labels Oct 12, 2018
@targos targos added code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. and removed code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. labels Oct 12, 2018
assert.throws(() => Buffer.alloc(8).writeFloatLE(0, 5), RangeError);
assert.throws(() => Buffer.alloc(16).writeDoubleLE(0, 9), RangeError);
assert.throws(() => Buffer.alloc(8).writeFloatLE(0, 5), {
code: 'ERR_OUT_OF_RANGE',
Copy link
Member

Choose a reason for hiding this comment

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

The object can be moved to a function, for example:

const getRangeError = (min, max, received) => ({
  code: 'ERR_OUT_OF_RANGE',
  name: 'RangeError [ERR_OUT_OF_RANGE]',
  message: `The value of "offset" is out of range. It must be >= ${min} ` +
  'and <= ${max}. Received ${received}'
});

And reused across the file

@addaleax
Copy link
Member

Uh … @Trott what do we do here? I think this conflicts quite a bit with your PR in https://github.com/nodejs/node/pull/23645…

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Looks good!

This needs a rebase, unfortunately, and I don’t know how tricky that gets…

@Trott Trott force-pushed the check-error-code-in-tests branch from be1f9c6 to f1e4160 Compare October 16, 2018 21:34
@Trott
Copy link
Member

Trott commented Oct 16, 2018

I rebased and force pushed to resolve the merge conflict.

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

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 17, 2018
Trott pushed a commit to Trott/io.js that referenced this pull request Oct 18, 2018
PR-URL: nodejs#23519
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
@Trott
Copy link
Member

Trott commented Oct 18, 2018

Landed in c208135

@Trott Trott closed this Oct 18, 2018
addaleax pushed a commit that referenced this pull request Oct 20, 2018
PR-URL: #23519
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
jasnell pushed a commit that referenced this pull request Oct 21, 2018
PR-URL: #23519
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request Oct 30, 2018
PR-URL: #23519
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
@codebytere codebytere mentioned this pull request Nov 27, 2018
rvagg pushed a commit that referenced this pull request Nov 28, 2018
PR-URL: #23519
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
PR-URL: #23519
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
@codebytere codebytere mentioned this pull request Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants