Skip to content

Commit b16dd98

Browse files
mhdawsonjasnell
authored andcommitted
test: consolidate n-api test addons
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. PR-URL: #13317 Reviewed-By: Jason Ginchereau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent e4f3756 commit b16dd98

File tree

7 files changed

+31
-72
lines changed

7 files changed

+31
-72
lines changed

test/addons-napi/test_globals/test.js test/addons-napi/test_general/testGlobals.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const common = require('../../common');
33
const assert = require('assert');
44

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

77
assert.strictEqual(test_globals.getUndefined(), undefined);
88
assert.strictEqual(test_globals.getNull(), null);

test/addons-napi/test_instanceof/test.js test/addons-napi/test_general/testInstanceOf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const assert = require('assert');
66

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

1212
// The following assert functions are referenced by v8's unit tests

test/addons-napi/test_general/test_general.c

+29
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,40 @@ napi_value testGetVersion(napi_env env, napi_callback_info info) {
3333
return result;
3434
}
3535

36+
napi_value doInstanceOf(napi_env env, napi_callback_info info) {
37+
size_t argc = 2;
38+
napi_value args[2];
39+
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
40+
41+
bool instanceof;
42+
NAPI_CALL(env, napi_instanceof(env, args[0], args[1], &instanceof));
43+
44+
napi_value result;
45+
NAPI_CALL(env, napi_get_boolean(env, instanceof, &result));
46+
47+
return result;
48+
}
49+
50+
napi_value getNull(napi_env env, napi_callback_info info) {
51+
napi_value result;
52+
NAPI_CALL(env, napi_get_null(env, &result));
53+
return result;
54+
}
55+
56+
napi_value getUndefined(napi_env env, napi_callback_info info) {
57+
napi_value result;
58+
NAPI_CALL(env, napi_get_undefined(env, &result));
59+
return result;
60+
}
61+
3662
void Init(napi_env env, napi_value exports, napi_value module, void* priv) {
3763
napi_property_descriptor descriptors[] = {
3864
DECLARE_NAPI_PROPERTY("testStrictEquals", testStrictEquals),
3965
DECLARE_NAPI_PROPERTY("testGetPrototype", testGetPrototype),
4066
DECLARE_NAPI_PROPERTY("testGetVersion", testGetVersion),
67+
DECLARE_NAPI_PROPERTY("doInstanceOf", doInstanceOf),
68+
DECLARE_NAPI_PROPERTY("getUndefined", getUndefined),
69+
DECLARE_NAPI_PROPERTY("getNull", getNull),
4170
};
4271

4372
NAPI_CALL_RETURN_VOID(env, napi_define_properties(

test/addons-napi/test_globals/binding.gyp

-8
This file was deleted.

test/addons-napi/test_globals/test_globals.c

-26
This file was deleted.

test/addons-napi/test_instanceof/binding.gyp

-8
This file was deleted.

test/addons-napi/test_instanceof/test_instanceof.c

-28
This file was deleted.

0 commit comments

Comments
 (0)