Skip to content

Commit a0cac77

Browse files
NickNasomhdawson
authored andcommitted
Added test for bool operator
PR-URL: #490 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent ab7d8fc commit a0cac77

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/basic_types/boolean.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ Value CreateBooleanFromPrimitive(const CallbackInfo& info) {
2121
return Boolean::New(info.Env(), boolean);
2222
}
2323

24+
Value OperatorBool(const CallbackInfo& info) {
25+
Boolean boolean(info.Env(), info[0].As<Boolean>());
26+
return Boolean::New(info.Env(), static_cast<bool>(boolean));
27+
}
28+
2429
Object InitBasicTypesBoolean(Env env) {
2530
Object exports = Object::New(env);
2631

2732
exports["createBoolean"] = Function::New(env, CreateBoolean);
2833
exports["createEmptyBoolean"] = Function::New(env, CreateEmptyBoolean);
2934
exports["createBooleanFromExistingValue"] = Function::New(env, CreateBooleanFromExistingValue);
3035
exports["createBooleanFromPrimitive"] = Function::New(env, CreateBooleanFromPrimitive);
36+
exports["operatorBool"] = Function::New(env, OperatorBool);
3137
return exports;
3238
}

test/basic_types/boolean.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@ function test(binding) {
2727
const bool6 = binding.basic_types_boolean.createBooleanFromPrimitive(false);
2828
assert.strictEqual(bool6, false);
2929

30+
const bool7 = binding.basic_types_boolean.operatorBool(true);
31+
assert.strictEqual(bool7, true);
32+
33+
const bool8 = binding.basic_types_boolean.operatorBool(false);
34+
assert.strictEqual(bool8, false);
35+
3036
}

0 commit comments

Comments
 (0)