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: fix up N-API error test #20487

Closed

Conversation

gabrielschulhof
Copy link
Contributor

Replace assert.throws() with an explicit try/catch in order to catch
the thrown value and be able to compare it strictly to an expected
value.

Re: #20428 (comment)

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

@nodejs-github-bot nodejs-github-bot added dont-land-on-v4.x node-api Issues and PRs related to the Node-API. test Issues and PRs related to the tests. labels May 3, 2018
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM, I suggest to keep assert.throws nevertheless.

thrownItem = something;
}
assert(hasThrown);
assert.strictEqual(thrownItem, value);
Copy link
Member

Choose a reason for hiding this comment

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

It is possible to use assert.throws when using the following notation:

assert.throws(
  () => test_error.throwArbitrary(value),
  (err) => {
    assert.strictEqual(err, value);
    return true;
  }
);

@gabrielschulhof
Copy link
Contributor Author

@BridgeAR I updated the check as you suggested.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@gabrielschulhof
Copy link
Contributor Author

Replace assert.throws() with an explicit try/catch in order to catch
the thrown value and be able to compare it strictly to an expected
value.

Re: nodejs#20428 (comment)
@gabrielschulhof
Copy link
Contributor Author

sigh ... linter ... new CI: https://ci.nodejs.org/job/node-test-pull-request/14658/

@BridgeAR BridgeAR added fast-track PRs that do not need to wait for 48 hours to land. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels May 4, 2018
@BridgeAR
Copy link
Member

BridgeAR commented May 4, 2018

Please +1 if you are fine with fast tracking.

@addaleax
Copy link
Member

addaleax commented May 5, 2018

Landed in 3b60fc2

@addaleax addaleax closed this May 5, 2018
addaleax pushed a commit that referenced this pull request May 5, 2018
Replace assert.throws() with an explicit try/catch in order to catch
the thrown value and be able to compare it strictly to an expected
value.

Re: #20428 (comment)

PR-URL: #20487
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 8, 2018
Replace assert.throws() with an explicit try/catch in order to catch
the thrown value and be able to compare it strictly to an expected
value.

Re: #20428 (comment)

PR-URL: #20487
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@MylesBorins MylesBorins mentioned this pull request May 8, 2018
MylesBorins pushed a commit that referenced this pull request May 8, 2018
Replace assert.throws() with an explicit try/catch in order to catch
the thrown value and be able to compare it strictly to an expected
value.

Re: #20428 (comment)

PR-URL: #20487
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 9, 2018
Replace assert.throws() with an explicit try/catch in order to catch
the thrown value and be able to compare it strictly to an expected
value.

Re: #20428 (comment)

PR-URL: #20487
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@gabrielschulhof gabrielschulhof deleted the n-api-fixup-test-error branch May 16, 2018 15:20
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. fast-track PRs that do not need to wait for 48 hours to land. node-api Issues and PRs related to the Node-API. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants