Skip to content

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-botnodejs-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

@addaleaxaddaleax 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
charbuffer[128];
size_tbuffer_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
MemberAuthor

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

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.

charbuffer[128];
size_tbuffer_size=128;
size_tcopied;
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
MemberAuthor

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
MemberAuthor

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

@mhdawson
Copy link
MemberAuthor

@mhdawson
Copy link
MemberAuthor

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
MemberAuthor

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
MemberAuthor

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

Landed as 1961900

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]>
@jasnelljasnell mentioned this pull request May 28, 2017
@mhdawsonmhdawson 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]>
@MylesBorinsMylesBorins mentioned this pull request Apr 16, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

node-apiIssues and PRs related to the Node-API.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@mhdawson@addaleax@cjihrig@jasongin@nodejs-github-bot