diff options
author | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-06-01 18:35:26 -0400 |
---|---|---|
committer | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-06-05 19:21:08 -0400 |
commit | bd4b79051a89867ff56850bb03fdc74460e117f4 (patch) | |
tree | fc28208b049e3cd37b5ff9253cca5ff238dd2801 /test | |
parent | 7cddcc971576aa4b22654132db1c9debbcc0839e (diff) | |
download | android-node-v8-bd4b79051a89867ff56850bb03fdc74460e117f4.tar.gz android-node-v8-bd4b79051a89867ff56850bb03fdc74460e117f4.tar.bz2 android-node-v8-bd4b79051a89867ff56850bb03fdc74460e117f4.zip |
test: consolidate n-api test addons - part2
It takes time to build each of the addons used to test n-api.
Consolidate a few of the smaller ones to save build time.
Get rid of one more small addon.
PR-URL: https://github.com/nodejs/node/pull/13380
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/addons-napi/test_general/testNapiStatus.js (renamed from test/addons-napi/test_napi_status/test.js) | 2 | ||||
-rw-r--r-- | test/addons-napi/test_general/test_general.c | 33 | ||||
-rw-r--r-- | test/addons-napi/test_napi_status/binding.gyp | 8 | ||||
-rw-r--r-- | test/addons-napi/test_napi_status/test_napi_status.cc | 45 |
4 files changed, 34 insertions, 54 deletions
diff --git a/test/addons-napi/test_napi_status/test.js b/test/addons-napi/test_general/testNapiStatus.js index 60c4f693b2..a588862098 100644 --- a/test/addons-napi/test_napi_status/test.js +++ b/test/addons-napi/test_general/testNapiStatus.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const addon = require(`./build/${common.buildType}/test_napi_status`); +const addon = require(`./build/${common.buildType}/test_general`); const assert = require('assert'); addon.createNapiError(); diff --git a/test/addons-napi/test_general/test_general.c b/test/addons-napi/test_general/test_general.c index 5d974081a4..0b69cc41e2 100644 --- a/test/addons-napi/test_general/test_general.c +++ b/test/addons-napi/test_general/test_general.c @@ -59,6 +59,37 @@ napi_value getUndefined(napi_env env, napi_callback_info info) { return result; } +napi_value createNapiError(napi_env env, napi_callback_info info) { + napi_value value; + NAPI_CALL(env, napi_create_string_utf8(env, "xyz", 3, &value)); + + double double_value; + napi_status status = napi_get_value_double(env, value, &double_value); + + NAPI_ASSERT(env, status != napi_ok, "Failed to produce error condition"); + + const napi_extended_error_info *error_info = 0; + NAPI_CALL(env, napi_get_last_error_info(env, &error_info)); + + NAPI_ASSERT(env, error_info->error_code == status, + "Last error info code should match last status"); + NAPI_ASSERT(env, error_info->error_message, + "Last error info message should not be null"); + + return NULL; +} + +napi_value testNapiErrorCleanup(napi_env env, napi_callback_info info) { + const napi_extended_error_info *error_info = 0; + NAPI_CALL(env, napi_get_last_error_info(env, &error_info)); + + napi_value result; + bool is_ok = error_info->error_code == napi_ok; + NAPI_CALL(env, napi_get_boolean(env, is_ok, &result)); + + return result; +} + void Init(napi_env env, napi_value exports, napi_value module, void* priv) { napi_property_descriptor descriptors[] = { DECLARE_NAPI_PROPERTY("testStrictEquals", testStrictEquals), @@ -67,6 +98,8 @@ void Init(napi_env env, napi_value exports, napi_value module, void* priv) { DECLARE_NAPI_PROPERTY("doInstanceOf", doInstanceOf), DECLARE_NAPI_PROPERTY("getUndefined", getUndefined), DECLARE_NAPI_PROPERTY("getNull", getNull), + DECLARE_NAPI_PROPERTY("createNapiError", createNapiError), + DECLARE_NAPI_PROPERTY("testNapiErrorCleanup", testNapiErrorCleanup), }; NAPI_CALL_RETURN_VOID(env, napi_define_properties( diff --git a/test/addons-napi/test_napi_status/binding.gyp b/test/addons-napi/test_napi_status/binding.gyp deleted file mode 100644 index 01ace540a9..0000000000 --- a/test/addons-napi/test_napi_status/binding.gyp +++ /dev/null @@ -1,8 +0,0 @@ -{ - "targets": [ - { - "target_name": "test_napi_status", - "sources": [ "test_napi_status.cc" ] - } - ] -} diff --git a/test/addons-napi/test_napi_status/test_napi_status.cc b/test/addons-napi/test_napi_status/test_napi_status.cc deleted file mode 100644 index 9e340aa46e..0000000000 --- a/test/addons-napi/test_napi_status/test_napi_status.cc +++ /dev/null @@ -1,45 +0,0 @@ -#include <node_api.h> -#include "../common.h" - -napi_value createNapiError(napi_env env, napi_callback_info info) { - napi_value value; - NAPI_CALL(env, napi_create_string_utf8(env, "xyz", 3, &value)); - - double double_value; - napi_status status = napi_get_value_double(env, value, &double_value); - - NAPI_ASSERT(env, status != napi_ok, "Failed to produce error condition"); - - const napi_extended_error_info *error_info = 0; - NAPI_CALL(env, napi_get_last_error_info(env, &error_info)); - - NAPI_ASSERT(env, error_info->error_code == status, - "Last error info code should match last status"); - NAPI_ASSERT(env, error_info->error_message, - "Last error info message should not be null"); - - return nullptr; -} - -napi_value testNapiErrorCleanup(napi_env env, napi_callback_info info) { - const napi_extended_error_info *error_info = 0; - NAPI_CALL(env, napi_get_last_error_info(env, &error_info)); - - napi_value result; - bool is_ok = error_info->error_code == napi_ok; - NAPI_CALL(env, napi_get_boolean(env, is_ok, &result)); - - return result; -} - -void Init(napi_env env, napi_value exports, napi_value module, void* priv) { - napi_property_descriptor descriptors[] = { - DECLARE_NAPI_PROPERTY("createNapiError", createNapiError), - DECLARE_NAPI_PROPERTY("testNapiErrorCleanup", testNapiErrorCleanup), - }; - - NAPI_CALL_RETURN_VOID(env, napi_define_properties( - env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors)); -} - -NAPI_MODULE(addon, Init) |