-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
First time contribution from NodeConf EU #16821
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.
Thanks @paulashfield — just some minor feedback below.
assert.strictEqual(addon.testNapiRun('(41.92 + 0.08);'), 42, | ||
'napi_run_script() works correctly'); | ||
assert.throws(() => addon.testNapiRun({ abc: 'def' }), /string was expected/); | ||
const args = [41.92, 0.08]; |
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 would be a bit nicer as just, say:
const val1 = 41.92;
const val2 = 0.08;
const args = [41.92, 0.08]; | ||
const testCase = '(' + args.join(' + ') + ');'; | ||
const expected = 43; | ||
const actual = addon.testNapiRun(testCase); |
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 could be then rewritten as:
const actual = addon.testNapiRun(`(${val1} + ${val2});`);
assert.throws(() => addon.testNapiRun({ abc: 'def' }), /string was expected/); | ||
const args = [41.92, 0.08]; | ||
const testCase = '(' + args.join(' + ') + ');'; | ||
const expected = 43; |
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 could then be const expected = val1 + val2;
const expected = 43; | ||
const actual = addon.testNapiRun(testCase); | ||
|
||
assert.strictEqual(actual, expected, `testNapiRun${testCase} gets ${actual} not expected ${expected}`); |
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.
Here you could remove the third argument (the error message) as the default message communicates the same thing.
@paulashfield -
on your system - implication of which is that this commit will not be associated with your profile. Can you set them up and push once again? |
@paulashfield See also the last note in this chapter: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#setting-up-your-local-environment |
const actual = addon.testNapiRun(testCase); | ||
|
||
assert.strictEqual(actual, expected, `testNapiRun${testCase} gets ${actual} not expected ${expected}`); | ||
assert.throws(() => addon.testNapiRun({abc: 'def'}), /string was expected/); |
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.
A nit: the last line seems lacking the last line break.
Many thanks all for feedback - really helped. I have amended and recommitted, hope that looks better. |
Hi @paulashfield! Welcome and thanks for the PR! If you run |
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.
Needs spacing flagged by linter fixed...
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.
Because the lint issue was just about adding two spaces, I went ahead and did it myself. Hope that's OK.
PR-URL: nodejs#16821 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Landed in 3ee524b. |
PR-URL: #16821 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
@paulashfield just an FYI, this commit isn't associated with your Github account. You need to go to https://github.com/settings/emails and add That's why there's a |
PR-URL: #16821 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
PR-URL: nodejs#16821 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Backport-PR-URL: #19447 PR-URL: #16821 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)