-
Notifications
You must be signed in to change notification settings - Fork 465
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
Adding unit tests for FunctionReference class #1035
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.
LGTM
@nodejs/node-api anybody else want to take a look before I land this? |
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.
Can you perform some formatting on your JavaScript sources? I see a lot of different spacing conventions between the tokens (eg. spaces between parameters)
test/functionreference.js
Outdated
let hook; | ||
const events = [] | ||
return new Promise((res, reject) =>{ | ||
console.log('Installing async hook') |
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.
We can remove this.
4986dce
to
c0396b3
Compare
test/binding.gyp
Outdated
@@ -27,6 +27,7 @@ | |||
'error.cc', | |||
'external.cc', | |||
'function.cc', | |||
'funcRefObject.cc', |
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.
Please make sure the file names and the name of the init function are consistent for #1078 by @deepakrkris!
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.
@deepakrkris this is interesting, because it creates a situation where a test file has a dependency. Maybe this class definition should go to the top of function_reference.cc instead because that's the only file using it. Then we can also avoid having to deal with file dependencies.
test/funcRefObject.h
Outdated
int _value; | ||
}; | ||
|
||
#endif |
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 newline.
test/function_reference.cc
Outdated
Napi::FunctionReference ref; | ||
ref.Reset(info[0].As<Function>()); | ||
|
||
Napi::AsyncContext contxt(info.Env(), "func_ref_resources", {}); |
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.
context
test/function_reference.cc
Outdated
args[argIdx] = info[i]; | ||
} | ||
|
||
Napi::AsyncContext contxt(info.Env(), "func_ref_resources", {}); |
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.
context
test/function_reference.cc
Outdated
exports["call"] = Function::New(env, Call); | ||
exports["construct"] = Function::New(env, Construct); | ||
|
||
return exports; | ||
} | ||
} |
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.
Please add a newline!
test/function_reference.js
Outdated
binding.AsyncCallWithArgv(testFuncB, 2, 4, 5, 6) === testFuncB(2, 4, 5, 6) | ||
); | ||
} | ||
function test (binding) { |
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 should be async because it should await canCallAsyncFunctionWithDifferentOverloads.
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.
... and it should itself be await
ed at the call site.
c0396b3
to
5eb3c5e
Compare
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.
LGTM
PR-URL: #1035 Reviewed-By: Michael Dawson <[email protected] Reviewed-By: Kevin Eady <[email protected]>
Landed as 04b26a9 |
PR-URL: nodejs/node-addon-api#1035 Reviewed-By: Michael Dawson <[email protected] Reviewed-By: Kevin Eady <[email protected]>
PR-URL: nodejs/node-addon-api#1035 Reviewed-By: Michael Dawson <[email protected] Reviewed-By: Kevin Eady <[email protected]>
PR-URL: nodejs/node-addon-api#1035 Reviewed-By: Michael Dawson <[email protected] Reviewed-By: Kevin Eady <[email protected]>
PR-URL: nodejs/node-addon-api#1035 Reviewed-By: Michael Dawson <[email protected] Reviewed-By: Kevin Eady <[email protected]>
Adding test coverage for FunctionReference class. #989