Skip to content
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

test: consolidate n-api test addons #13317

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const common = require('../../common');
const assert = require('assert');

const test_globals = require(`./build/${common.buildType}/test_globals`);
const test_globals = require(`./build/${common.buildType}/test_general`);

assert.strictEqual(test_globals.getUndefined(), undefined);
assert.strictEqual(test_globals.getNull(), null);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const assert = require('assert');

// addon is referenced through the eval expression in testFile
// eslint-disable-next-line no-unused-vars
const addon = require(`./build/${common.buildType}/test_instanceof`);
const addon = require(`./build/${common.buildType}/test_general`);
const path = require('path');

// The following assert functions are referenced by v8's unit tests
Expand Down
29 changes: 29 additions & 0 deletions test/addons-napi/test_general/test_general.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,40 @@ napi_value testGetVersion(napi_env env, napi_callback_info info) {
return result;
}

napi_value doInstanceOf(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

bool instanceof;
NAPI_CALL(env, napi_instanceof(env, args[0], args[1], &instanceof));

napi_value result;
NAPI_CALL(env, napi_get_boolean(env, instanceof, &result));

return result;
}

napi_value getNull(napi_env env, napi_callback_info info) {
napi_value result;
NAPI_CALL(env, napi_get_null(env, &result));
return result;
}

napi_value getUndefined(napi_env env, napi_callback_info info) {
napi_value result;
NAPI_CALL(env, napi_get_undefined(env, &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),
DECLARE_NAPI_PROPERTY("testGetPrototype", testGetPrototype),
DECLARE_NAPI_PROPERTY("testGetVersion", testGetVersion),
DECLARE_NAPI_PROPERTY("doInstanceOf", doInstanceOf),
DECLARE_NAPI_PROPERTY("getUndefined", getUndefined),
DECLARE_NAPI_PROPERTY("getNull", getNull),
};

NAPI_CALL_RETURN_VOID(env, napi_define_properties(
Expand Down
8 changes: 0 additions & 8 deletions test/addons-napi/test_globals/binding.gyp

This file was deleted.

26 changes: 0 additions & 26 deletions test/addons-napi/test_globals/test_globals.c

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/test_instanceof/binding.gyp

This file was deleted.

28 changes: 0 additions & 28 deletions test/addons-napi/test_instanceof/test_instanceof.c

This file was deleted.