From 79b1bf5a09ee18a9dda6e05f23e3920609bc8cab Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 25 Jun 2019 16:25:48 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/28423 Fixes: https://github.com/nodejs/help/issues/1998 Reviewed-By: Gireesh Punathil Reviewed-By: Yongsheng Zhang Reviewed-By: Colin Ihrig Reviewed-By: Gabriel Schulhof Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- test/node-api/test_async/test_async.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/node-api/test_async/test_async.cc b/test/node-api/test_async/test_async.cc index 49db7aa66f190b..ff3d2749a9d184 100644 --- a/test/node-api/test_async/test_async.cc +++ b/test/node-api/test_async/test_async.cc @@ -1,3 +1,4 @@ +#include #include #include #include "../../js-native-api/common.h" @@ -29,10 +30,7 @@ void Execute(napi_env env, void* data) { #endif carrier* c = static_cast(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; }