| 81 | assert(adjustedValue > 0); |
| 82 | |
| 83 | async function runGCTests() { |
| 84 | // Ensure that garbage collecting an object with a wrapped native item results |
| 85 | // in the finalize callback being called. |
| 86 | assert.strictEqual(test_general.derefItemWasCalled(), false); |
| 87 | |
| 88 | (() => test_general.wrap({}))(); |
| 89 | await gcUntil('deref_item() was called upon garbage collecting a ' + |
| 90 | 'wrapped object.', |
| 91 | () => test_general.derefItemWasCalled()); |
| 92 | |
| 93 | // Ensure that removing a wrap and garbage collecting does not fire the |
| 94 | // finalize callback. |
| 95 | let z = {}; |
| 96 | test_general.testFinalizeWrap(z); |
| 97 | test_general.removeWrap(z); |
| 98 | z = null; |
| 99 | await gcUntil( |
| 100 | 'finalize callback was not called upon garbage collection.', |
| 101 | () => (!test_general.finalizeWasCalled())); |
| 102 | } |
| 103 | runGCTests(); |