11cb0ef41Sopenharmony_ci// Flags: --expose-internals --expose-gc 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding'); 61cb0ef41Sopenharmony_ciconst { WeakReference } = internalBinding('util'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cilet obj = { hello: 'world' }; 91cb0ef41Sopenharmony_ciconst ref = new WeakReference(obj); 101cb0ef41Sopenharmony_ciassert.strictEqual(ref.get(), obj); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cisetImmediate(() => { 131cb0ef41Sopenharmony_ci obj = null; 141cb0ef41Sopenharmony_ci global.gc(); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci assert.strictEqual(ref.get(), undefined); 171cb0ef41Sopenharmony_ci}); 18