File tree Expand file tree Collapse file tree 5 files changed +33
-0
lines changed
Expand file tree Collapse file tree 5 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ #include " napi.h"
2+
3+ using namespace Napi ;
4+
5+ Value CreateBoolean (const CallbackInfo& info) {
6+ return Boolean::New (info.Env (), info[0 ].As <Boolean>().Value ());
7+ }
8+
9+ Object InitBasicTypesBoolean (Env env) {
10+ Object exports = Object::New (env);
11+
12+ exports[" createBoolean" ] = Function::New (env, CreateBoolean);
13+
14+ return exports;
15+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const buildType = process . config . target_defaults . default_configuration ;
3+ const assert = require ( 'assert' ) ;
4+
5+ test ( require ( `../build/${ buildType } /binding.node` ) ) ;
6+ test ( require ( `../build/${ buildType } /binding_noexcept.node` ) ) ;
7+
8+ function test ( binding ) {
9+ const bool1 = binding . basic_types_boolean . createBoolean ( true ) ;
10+ assert . strictEqual ( bool1 , true ) ;
11+
12+ const bool2 = binding . basic_types_boolean . createBoolean ( false ) ;
13+ assert . strictEqual ( bool2 , false ) ;
14+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ using namespace Napi;
44
55Object InitArrayBuffer (Env env);
66Object InitAsyncWorker (Env env);
7+ Object InitBasicTypesBoolean (Env env);
78Object InitBasicTypesNumber (Env env);
89Object InitBasicTypesValue (Env env);
910Object InitBigInt (Env env);
@@ -25,6 +26,7 @@ Object InitObjectReference(Env env);
2526Object Init (Env env, Object exports) {
2627 exports.Set (" arraybuffer" , InitArrayBuffer (env));
2728 exports.Set (" asyncworker" , InitAsyncWorker (env));
29+ exports.Set (" basic_types_boolean" , InitBasicTypesBoolean (env));
2830 exports.Set (" basic_types_number" , InitBasicTypesNumber (env));
2931 exports.Set (" basic_types_value" , InitBasicTypesValue (env));
3032 exports.Set (" bigint" , InitBigInt (env));
Original file line number Diff line number Diff line change 33 'sources' : [
44 'arraybuffer.cc' ,
55 'asyncworker.cc' ,
6+ 'basic_types/boolean.cc' ,
67 'basic_types/number.cc' ,
78 'basic_types/value.cc' ,
89 'bigint.cc' ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ process.config.target_defaults.default_configuration =
1010let testModules = [
1111 'arraybuffer' ,
1212 'asyncworker' ,
13+ 'basic_types/boolean' ,
1314 'basic_types/number' ,
1415 'basic_types/value' ,
1516 'bigint' ,
You can’t perform that action at this time.
0 commit comments