From a0cac77c82b3676369a7d19cdd393208a22b14ac Mon Sep 17 00:00:00 2001 From: NickNaso Date: Mon, 10 Jun 2019 15:08:40 +0200 Subject: [PATCH] Added test for bool operator PR-URL: https://github.com/nodejs/node-addon-api/pull/490 Reviewed-By: Michael Dawson --- test/basic_types/boolean.cc | 6 ++++++ test/basic_types/boolean.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/test/basic_types/boolean.cc b/test/basic_types/boolean.cc index fd6e3165f..4abacece4 100644 --- a/test/basic_types/boolean.cc +++ b/test/basic_types/boolean.cc @@ -21,6 +21,11 @@ Value CreateBooleanFromPrimitive(const CallbackInfo& info) { return Boolean::New(info.Env(), boolean); } +Value OperatorBool(const CallbackInfo& info) { + Boolean boolean(info.Env(), info[0].As()); + return Boolean::New(info.Env(), static_cast(boolean)); +} + Object InitBasicTypesBoolean(Env env) { Object exports = Object::New(env); @@ -28,5 +33,6 @@ Object InitBasicTypesBoolean(Env env) { exports["createEmptyBoolean"] = Function::New(env, CreateEmptyBoolean); exports["createBooleanFromExistingValue"] = Function::New(env, CreateBooleanFromExistingValue); exports["createBooleanFromPrimitive"] = Function::New(env, CreateBooleanFromPrimitive); + exports["operatorBool"] = Function::New(env, OperatorBool); return exports; } diff --git a/test/basic_types/boolean.js b/test/basic_types/boolean.js index 1c27664f1..13817ee52 100644 --- a/test/basic_types/boolean.js +++ b/test/basic_types/boolean.js @@ -27,4 +27,10 @@ function test(binding) { const bool6 = binding.basic_types_boolean.createBooleanFromPrimitive(false); assert.strictEqual(bool6, false); + const bool7 = binding.basic_types_boolean.operatorBool(true); + assert.strictEqual(bool7, true); + + const bool8 = binding.basic_types_boolean.operatorBool(false); + assert.strictEqual(bool8, false); + }