Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 79b1bf5

Browse filesBrowse files
addaleaxtargos
authored andcommitted
test: use assert() in N-API async test
The `Execute()` callback is not allowed to call into JS, so we should use `assert()` instead of potentially throwing JS errors. PR-URL: #28423 Fixes: nodejs/help#1998 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 14f6cee commit 79b1bf5
Copy full SHA for 79b1bf5

File tree

Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed
Open diff view settings
Collapse file

‎test/node-api/test_async/test_async.cc‎

Copy file name to clipboardExpand all lines: test/node-api/test_async/test_async.cc
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <assert.h>
12
#include <stdio.h>
23
#include <node_api.h>
34
#include "../../js-native-api/common.h"
@@ -29,10 +30,7 @@ void Execute(napi_env env, void* data) {
2930
#endif
3031
carrier* c = static_cast<carrier*>(data);
3132

32-
if (c != &the_carrier) {
33-
napi_throw_type_error(env, nullptr, "Wrong data parameter to Execute.");
34-
return;
35-
}
33+
assert(c == &the_carrier);
3634

3735
c->_output = c->_input * 2;
3836
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.