test: improve error message output
PR-URL: https://github.com/nodejs/node/pull/18498 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
parent
4ac7be94f0
commit
5ecd2e15b8
@ -63,22 +63,25 @@ let w = {};
|
|||||||
test_general.wrap(w);
|
test_general.wrap(w);
|
||||||
w = null;
|
w = null;
|
||||||
global.gc();
|
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 ' +
|
'deref_item() was called upon garbage collecting a ' +
|
||||||
'wrapped object');
|
'wrapped object. test_general.derefItemWasCalled() ' +
|
||||||
|
`returned ${derefItemWasCalled}`);
|
||||||
|
|
||||||
|
|
||||||
// Assert that wrapping twice fails.
|
// Assert that wrapping twice fails.
|
||||||
const x = {};
|
const x = {};
|
||||||
test_general.wrap(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.
|
// Ensure that wrapping, removing the wrap, and then wrapping again works.
|
||||||
const y = {};
|
const y = {};
|
||||||
test_general.wrap(y);
|
test_general.wrap(y);
|
||||||
test_general.removeWrap(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()' +
|
assert.doesNotThrow(() => test_general.wrap(y));
|
||||||
' separates the instances');
|
|
||||||
|
|
||||||
// Ensure that removing a wrap and garbage collecting does not fire the
|
// Ensure that removing a wrap and garbage collecting does not fire the
|
||||||
// finalize callback.
|
// finalize callback.
|
||||||
@ -87,8 +90,11 @@ test_general.testFinalizeWrap(z);
|
|||||||
test_general.removeWrap(z);
|
test_general.removeWrap(z);
|
||||||
z = null;
|
z = null;
|
||||||
global.gc();
|
global.gc();
|
||||||
assert.strictEqual(test_general.finalizeWasCalled(), false,
|
const finalizeWasCalled = test_general.finalizeWasCalled();
|
||||||
'finalize callback was not called upon garbage collection');
|
assert.strictEqual(finalizeWasCalled, false,
|
||||||
|
'finalize callback was not called upon garbage collection.' +
|
||||||
|
' test_general.finalizeWasCalled() ' +
|
||||||
|
`returned ${finalizeWasCalled}`);
|
||||||
|
|
||||||
// test napi_adjust_external_memory
|
// test napi_adjust_external_memory
|
||||||
const adjustedValue = test_general.testAdjustExternalMemory();
|
const adjustedValue = test_general.testAdjustExternalMemory();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user