Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Fixes: nodejs/help#1998
  • Loading branch information
addaleax committed Jun 25, 2019
commit a83a20ff176feec530740bd1ebdc83533826dc11
6 changes: 2 additions & 4 deletions test/node-api/test_async/test_async.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <assert.h>
#include <stdio.h>
#include <node_api.h>
#include "../../js-native-api/common.h"
Expand Down Expand Up @@ -29,10 +30,7 @@ void Execute(napi_env env, void* data) {
#endif
carrier* c = static_cast<carrier*>(data);

if (c != &the_carrier) {
napi_throw_type_error(env, nullptr, "Wrong data parameter to Execute.");
return;
}
assert(c == &the_carrier);

c->_output = c->_input * 2;
}
Expand Down