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: add coverage for napi_has_named_property #13178

Closed
wants to merge 2 commits into from

Conversation

mhdawson
Copy link
Member

Add test to cover napi_has_named_property

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

test, n-api

Add test to cover napi_has_named_property
@nodejs-github-bot nodejs-github-bot added node-api Issues and PRs related to the Node-API. test Issues and PRs related to the tests. labels May 23, 2017
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.

good


// Extract the name of the property to check
char buffer[128];
size_t buffer_size = 128;
Copy link
Member

Choose a reason for hiding this comment

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

I mean, this is obviously correct, but I get all tingly seeing this not just use sizeof(buffer). 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Not an excuse but I copied from the existing code in another file, using sizeof does seem better so I'll move it over to that.

NAPI_CALL(env,
napi_get_value_string_utf8(env, args[1], buffer, buffer_size - 1, &copied));

// do the check and create the boolean retutn value
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: retutn

@@ -39,3 +39,7 @@ test_object.readwriteAccessor2 = 2;
assert.strictEqual(test_object.readwriteAccessor2, 2);
assert.strictEqual(test_object.readonlyAccessor2, 2);
assert.throws(() => { test_object.readonlyAccessor2 = 3; }, TypeError);

assert.ok(test_object.hasNamedProperty(test_object, 'echo'));
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to use strictEqual() here to make sure we're actually getting a Boolean back.

char buffer[128];
size_t buffer_size = 128;
size_t copied;
buffer[buffer_size - 1] = 0;
Copy link
Member

Choose a reason for hiding this comment

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

napi_get_value_string_utf8() will always null-terminate, so this line should not be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok thanks.

@mhdawson
Copy link
Member Author

Thanks for the comments, pushed commit to address. Will land once 48 hours has passed.

@mhdawson
Copy link
Member Author

@mhdawson
Copy link
Member Author

Re-run on linux-one https://ci.nodejs.org/job/node-test-commit-linuxone/6151/. Original failure looks like infra issues as opposed to anything else.

@mhdawson
Copy link
Member Author

Failures on arm are both unrelated (both are failures of test-npm-install). Possible an infra failure at the time they were running. Going to lan.

@mhdawson
Copy link
Member Author

Should have noted re-run on linuxone was fine as well.

Landed as 1961900

@mhdawson mhdawson closed this May 25, 2017
mhdawson added a commit that referenced this pull request May 25, 2017
Add test to cover napi_has_named_property

PR-URL: #13178
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
jasnell pushed a commit that referenced this pull request May 28, 2017
Add test to cover napi_has_named_property

PR-URL: #13178
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
@jasnell jasnell mentioned this pull request May 28, 2017
@mhdawson mhdawson deleted the napi-cov7 branch June 28, 2017 19:23
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 10, 2018
Add test to cover napi_has_named_property

PR-URL: nodejs#13178
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
Add test to cover napi_has_named_property

Backport-PR-URL: #19447
PR-URL: #13178
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Apr 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants