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: https://github.com/nodejs/node/pull/13317 Reviewed-By: Jason Ginchereau <jasongin@microsoft.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
8440777553
commit
7a7ac1c6db
@ -2,7 +2,7 @@
|
|||||||
const common = require('../../common');
|
const common = require('../../common');
|
||||||
const assert = require('assert');
|
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.getUndefined(), undefined);
|
||||||
assert.strictEqual(test_globals.getNull(), null);
|
assert.strictEqual(test_globals.getNull(), null);
|
@ -6,7 +6,7 @@ const assert = require('assert');
|
|||||||
|
|
||||||
// addon is referenced through the eval expression in testFile
|
// addon is referenced through the eval expression in testFile
|
||||||
// eslint-disable-next-line no-unused-vars
|
// 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');
|
const path = require('path');
|
||||||
|
|
||||||
// The following assert functions are referenced by v8's unit tests
|
// The following assert functions are referenced by v8's unit tests
|
@ -33,11 +33,40 @@ napi_value testGetVersion(napi_env env, napi_callback_info info) {
|
|||||||
return result;
|
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) {
|
void Init(napi_env env, napi_value exports, napi_value module, void* priv) {
|
||||||
napi_property_descriptor descriptors[] = {
|
napi_property_descriptor descriptors[] = {
|
||||||
DECLARE_NAPI_PROPERTY("testStrictEquals", testStrictEquals),
|
DECLARE_NAPI_PROPERTY("testStrictEquals", testStrictEquals),
|
||||||
DECLARE_NAPI_PROPERTY("testGetPrototype", testGetPrototype),
|
DECLARE_NAPI_PROPERTY("testGetPrototype", testGetPrototype),
|
||||||
DECLARE_NAPI_PROPERTY("testGetVersion", testGetVersion),
|
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(
|
NAPI_CALL_RETURN_VOID(env, napi_define_properties(
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target_name": "test_globals",
|
|
||||||
"sources": [ "test_globals.c" ]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
#include <node_api.h>
|
|
||||||
#include "../common.h"
|
|
||||||
|
|
||||||
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("getUndefined", getUndefined),
|
|
||||||
DECLARE_NAPI_PROPERTY("getNull", getNull),
|
|
||||||
};
|
|
||||||
|
|
||||||
NAPI_CALL_RETURN_VOID(env, napi_define_properties(
|
|
||||||
env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors));
|
|
||||||
}
|
|
||||||
|
|
||||||
NAPI_MODULE(addon, Init)
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target_name": "test_instanceof",
|
|
||||||
"sources": [ "test_instanceof.c" ]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
#include <node_api.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "../common.h"
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init(napi_env env, napi_value exports, napi_value module, void* priv) {
|
|
||||||
napi_property_descriptor descriptors[] = {
|
|
||||||
DECLARE_NAPI_PROPERTY("doInstanceOf", doInstanceOf),
|
|
||||||
};
|
|
||||||
|
|
||||||
NAPI_CALL_RETURN_VOID(env, napi_define_properties(
|
|
||||||
env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors));
|
|
||||||
}
|
|
||||||
|
|
||||||
NAPI_MODULE(addon, Init)
|
|
Loading…
x
Reference in New Issue
Block a user