11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst fs = require('fs'); 71cb0ef41Sopenharmony_ciconst path = require('path'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_citmpdir.refresh(); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst fooPath = path.join(tmpdir.path, 'foo.cjs'); 121cb0ef41Sopenharmony_cifs.writeFileSync(fooPath, ''); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst dirPath = path.join(tmpdir.path, 'delete_me'); 151cb0ef41Sopenharmony_cifs.mkdirSync(dirPath, { 161cb0ef41Sopenharmony_ci recursive: true 171cb0ef41Sopenharmony_ci}); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciconst barPath = path.join(dirPath, 'bar.cjs'); 201cb0ef41Sopenharmony_cifs.writeFileSync(barPath, ` 211cb0ef41Sopenharmony_ci module.exports = () => require('../foo.cjs').call() 221cb0ef41Sopenharmony_ci`); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciconst foo = require(fooPath); 251cb0ef41Sopenharmony_ciconst unique = Symbol('unique'); 261cb0ef41Sopenharmony_cifoo.call = common.mustCall(() => unique); 271cb0ef41Sopenharmony_ciconst bar = require(barPath); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_cifs.rmSync(dirPath, { recursive: true }); 301cb0ef41Sopenharmony_ciassert.strict.equal(bar(), unique); 31