From 779ee360808020830e837b46801056b44f29eaf7 Mon Sep 17 00:00:00 2001 From: Bhavani Shankar Date: Thu, 1 Feb 2018 15:32:41 +0530 Subject: [PATCH 1/4] show output of derefItemWasCalled, finalizeWasCalled in message --- test/addons-napi/test_general/test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/addons-napi/test_general/test.js b/test/addons-napi/test_general/test.js index c89d718ca18575..857ff933c6121c 100644 --- a/test/addons-napi/test_general/test.js +++ b/test/addons-napi/test_general/test.js @@ -63,9 +63,12 @@ let w = {}; test_general.wrap(w); w = null; global.gc(); -assert.strictEqual(test_general.derefItemWasCalled(), true, +const derefItemWasCalled = test_general.derefItemWasCalled(); +assert.strictEqual(derefItemWasCalled, true, 'deref_item() was called upon garbage collecting a ' + - 'wrapped object'); + 'wrapped object. test_general.derefItemWasCalled() ' + + `returned ${derefItemWasCalled}`); + // Assert that wrapping twice fails. const x = {}; @@ -87,8 +90,11 @@ test_general.testFinalizeWrap(z); test_general.removeWrap(z); z = null; global.gc(); -assert.strictEqual(test_general.finalizeWasCalled(), false, - 'finalize callback was not called upon garbage collection'); +const finalizeWasCalled = test_general.finalizeWasCalled(); +assert.strictEqual(finalizeWasCalled, false, + 'finalize callback was not called upon garbage collection' + + 'test_general.finalizeWasCalled() ' + + `returned ${finalizeWasCalled}`); // test napi_adjust_external_memory const adjustedValue = test_general.testAdjustExternalMemory(); From c877c55ca4b62217e6750900774cb0ec2eb18c8c Mon Sep 17 00:00:00 2001 From: Bhavani Shankar Date: Thu, 1 Feb 2018 15:37:51 +0530 Subject: [PATCH 2/4] remove arg, replace message with comment in assert.doesNotThrow --- test/addons-napi/test_general/test.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/addons-napi/test_general/test.js b/test/addons-napi/test_general/test.js index 857ff933c6121c..81b49d86e5547d 100644 --- a/test/addons-napi/test_general/test.js +++ b/test/addons-napi/test_general/test.js @@ -79,9 +79,8 @@ assert.throws(() => test_general.wrap(x), Error); const y = {}; test_general.wrap(y); test_general.removeWrap(y); -assert.doesNotThrow(() => test_general.wrap(y), Error, - 'Wrapping twice succeeds if a remove_wrap()' + - ' separates the instances'); +// Wrapping twice succeeds if a remove_wrap() separates the instances +assert.doesNotThrow(() => test_general.wrap(y)) // Ensure that removing a wrap and garbage collecting does not fire the // finalize callback. From e77fe83fc8a76e187a9221b6e95af6c240fb7332 Mon Sep 17 00:00:00 2001 From: Bhavani Shankar Date: Thu, 1 Feb 2018 15:48:37 +0530 Subject: [PATCH 3/4] validate the error message when wrapping twice --- test/addons-napi/test_general/test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/addons-napi/test_general/test.js b/test/addons-napi/test_general/test.js index 81b49d86e5547d..fd8d4bdb7cf0a5 100644 --- a/test/addons-napi/test_general/test.js +++ b/test/addons-napi/test_general/test.js @@ -73,14 +73,15 @@ assert.strictEqual(derefItemWasCalled, true, // Assert that wrapping twice fails. const x = {}; test_general.wrap(x); -assert.throws(() => test_general.wrap(x), Error); +common.expectsError(() => test_general.wrap(x), + { type: Error, message: 'Invalid argument' }); // Ensure that wrapping, removing the wrap, and then wrapping again works. const y = {}; test_general.wrap(y); test_general.removeWrap(y); // Wrapping twice succeeds if a remove_wrap() separates the instances -assert.doesNotThrow(() => test_general.wrap(y)) +assert.doesNotThrow(() => test_general.wrap(y)); // Ensure that removing a wrap and garbage collecting does not fire the // finalize callback. From 16169baaa128220819c3f4e9f3dc527c26102e0e Mon Sep 17 00:00:00 2001 From: Bhavani Shankar Date: Fri, 2 Feb 2018 08:55:48 +0530 Subject: [PATCH 4/4] test: add spacing between two lines in a message --- test/addons-napi/test_general/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/addons-napi/test_general/test.js b/test/addons-napi/test_general/test.js index fd8d4bdb7cf0a5..bcaa13d894bedc 100644 --- a/test/addons-napi/test_general/test.js +++ b/test/addons-napi/test_general/test.js @@ -92,8 +92,8 @@ z = null; global.gc(); const finalizeWasCalled = test_general.finalizeWasCalled(); assert.strictEqual(finalizeWasCalled, false, - 'finalize callback was not called upon garbage collection' + - 'test_general.finalizeWasCalled() ' + + 'finalize callback was not called upon garbage collection.' + + ' test_general.finalizeWasCalled() ' + `returned ${finalizeWasCalled}`); // test napi_adjust_external_memory