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;
4
4
5
5
Object InitArrayBuffer (Env env);
6
6
Object InitAsyncWorker (Env env);
7
+ Object InitBasicTypesBoolean (Env env);
7
8
Object InitBasicTypesNumber (Env env);
8
9
Object InitBasicTypesValue (Env env);
9
10
Object InitBigInt (Env env);
@@ -25,6 +26,7 @@ Object InitObjectReference(Env env);
25
26
Object Init (Env env, Object exports) {
26
27
exports.Set (" arraybuffer" , InitArrayBuffer (env));
27
28
exports.Set (" asyncworker" , InitAsyncWorker (env));
29
+ exports.Set (" basic_types_boolean" , InitBasicTypesBoolean (env));
28
30
exports.Set (" basic_types_number" , InitBasicTypesNumber (env));
29
31
exports.Set (" basic_types_value" , InitBasicTypesValue (env));
30
32
exports.Set (" bigint" , InitBigInt (env));
Original file line number Diff line number Diff line change 3
3
'sources' : [
4
4
'arraybuffer.cc' ,
5
5
'asyncworker.cc' ,
6
+ 'basic_types/boolean.cc' ,
6
7
'basic_types/number.cc' ,
7
8
'basic_types/value.cc' ,
8
9
'bigint.cc' ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ process.config.target_defaults.default_configuration =
10
10
let testModules = [
11
11
'arraybuffer' ,
12
12
'asyncworker' ,
13
+ 'basic_types/boolean' ,
13
14
'basic_types/number' ,
14
15
'basic_types/value' ,
15
16
'bigint' ,
You can’t perform that action at this time.
0 commit comments