11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding'); 71cb0ef41Sopenharmony_ciconst { ModuleWrap } = internalBinding('module_wrap'); 81cb0ef41Sopenharmony_ciconst { getPromiseDetails, isPromise } = internalBinding('util'); 91cb0ef41Sopenharmony_ciconst setTimeoutAsync = require('util').promisify(setTimeout); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst foo = new ModuleWrap('foo', undefined, 'export * from "bar";', 0, 0); 121cb0ef41Sopenharmony_ciconst bar = new ModuleWrap('bar', undefined, 'export const five = 5', 0, 0); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci(async () => { 151cb0ef41Sopenharmony_ci const promises = foo.link(() => setTimeoutAsync(1000).then(() => bar)); 161cb0ef41Sopenharmony_ci assert.strictEqual(promises.length, 1); 171cb0ef41Sopenharmony_ci assert(isPromise(promises[0])); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci await Promise.all(promises); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci assert.strictEqual(getPromiseDetails(promises[0])[1], bar); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci foo.instantiate(); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci assert.strictEqual(await foo.evaluate(-1, false), undefined); 261cb0ef41Sopenharmony_ci assert.strictEqual(foo.getNamespace().five, 5); 271cb0ef41Sopenharmony_ci})().then(common.mustCall()); 28