11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Flags: --expose-gc --no-concurrent-array-buffer-sweeping 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst common = require('../../common'); 51cb0ef41Sopenharmony_ciconst binding = require(`./build/${common.buildType}/test_buffer`); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst tick = require('util').promisify(require('../../common/tick')); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci(async function() { 101cb0ef41Sopenharmony_ci assert.strictEqual(binding.newBuffer().toString(), binding.theText); 111cb0ef41Sopenharmony_ci assert.strictEqual(binding.newExternalBuffer().toString(), binding.theText); 121cb0ef41Sopenharmony_ci console.log('gc1'); 131cb0ef41Sopenharmony_ci global.gc(); 141cb0ef41Sopenharmony_ci assert.strictEqual(binding.getDeleterCallCount(), 0); 151cb0ef41Sopenharmony_ci await tick(10); 161cb0ef41Sopenharmony_ci assert.strictEqual(binding.getDeleterCallCount(), 1); 171cb0ef41Sopenharmony_ci assert.strictEqual(binding.copyBuffer().toString(), binding.theText); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci let buffer = binding.staticBuffer(); 201cb0ef41Sopenharmony_ci assert.strictEqual(binding.bufferHasInstance(buffer), true); 211cb0ef41Sopenharmony_ci assert.strictEqual(binding.bufferInfo(buffer), true); 221cb0ef41Sopenharmony_ci buffer = null; 231cb0ef41Sopenharmony_ci global.gc(); 241cb0ef41Sopenharmony_ci assert.strictEqual(binding.getDeleterCallCount(), 1); 251cb0ef41Sopenharmony_ci await tick(10); 261cb0ef41Sopenharmony_ci console.log('gc2'); 271cb0ef41Sopenharmony_ci assert.strictEqual(binding.getDeleterCallCount(), 2); 281cb0ef41Sopenharmony_ci})().then(common.mustCall()); 29