-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: add coverage for napi_typeof #13990
Conversation
We had some, but not complete coverage indirectly through other tests. Add test to validate it specifically and covers cases that were not being covered.
@@ -34,3 +34,12 @@ assert.ok(test_general.testGetPrototype(baseObject) !== | |||
// test version management functions | |||
// expected version is currently 1 | |||
assert.strictEqual(test_general.testGetVersion(), 1); | |||
|
|||
[123, 'test string', function() {}, new Object(), true, | |||
undefined, Symbol()].forEach((val) => { |
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.
Small readability nit
[
123,
'test string',
function() {},
new Object(),
true,
undefined,
Symbol()
].forEach( ... )
|
||
napi_value result; | ||
if (object_type == napi_number) { | ||
NAPI_CALL(env ,napi_create_number(env, 42, &result)); |
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.
The comma after env
is misaligned.
napi_value args[1]; | ||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); | ||
|
||
napi_valuetype object_type; |
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 think something like argument_type
would be more descriptive of what this variable is.
|
||
[123, 'test string', function() {}, new Object(), true, | ||
undefined, Symbol()].forEach((val) => { | ||
assert.strictEqual(typeof val, typeof (test_general.testNapiTypeof(val))); |
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.
Since this test is specifically for napi_typeof()
, I don't understand why test_general.testNapiTypeof()
returns a value of that type instead of just a string representing the type. Then, this assertion could be:
assert.strictEqual(typeof val, test_general.testNapiTypeof(val));
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.
That would probably work as well. Just not what I can up with. I'll take a look as its probably an easy change.
Pushed commit to address comments. |
@@ -29,7 +29,7 @@ napi_value testGetVersion(napi_env env, napi_callback_info info) { | |||
uint32_t version; | |||
napi_value result; | |||
NAPI_CALL(env, napi_get_version(env, &version)); | |||
NAPI_CALL(env ,napi_create_number(env, version, &result)); | |||
NAPI_CALL(env,napi_create_number(env, version, &result)); |
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.
Missing a space after the first comma.
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.
fixed
undefined, | ||
Symbol() | ||
].forEach((val) => { | ||
assert.strictEqual(typeof val, test_general.testNapiTypeof(val)); |
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.
Oh. A tiny nit here and on line 52. I think the parameter order should be switched to reflect actual, 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.
Thanks for catching that will update.
Pushed commit to address final comments CI run: https://ci.nodejs.org/job/node-test-pull-request/8994/ |
Landed as 34cf8ad |
We had some, but not complete coverage indirectly through other tests. Add test to validate it specifically and covers cases that were not being covered. PR-URL: #13990 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
This test is failing consistently for me locally on macOS. |
Running |
We had some, but not complete coverage indirectly through other tests. Add test to validate it specifically and covers cases that were not being covered. PR-URL: #13990 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
We had some, but not complete coverage indirectly through other tests. Add test to validate it specifically and covers cases that were not being covered. PR-URL: #13990 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
We had some, but not complete coverage indirectly through other tests. Add test to validate it specifically and covers cases that were not being covered. PR-URL: #13990 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
We had some, but not complete coverage indirectly through other tests. Add test to validate it specifically and covers cases that were not being covered. PR-URL: nodejs#13990 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
We had some, but not complete coverage indirectly through other tests. Add test to validate it specifically and covers cases that were not being covered. Backport-PR-URL: #19447 PR-URL: #13990 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
We had some, but not complete coverage indirectly through
other tests. Add test to validate it specifically and
covers cases that were not being covered.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test, n-api