11cb0ef41Sopenharmony_ciconst { Module: { createRequire } } = require('module'); 21cb0ef41Sopenharmony_ciconst createdRequire = createRequire(__filename); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// Although, require('../common') works locally, that couldn't be used here 51cb0ef41Sopenharmony_ci// because we set NODE_TEST_DIR=/Users/iojs/node-tmp on Jenkins CI. 61cb0ef41Sopenharmony_ciconst { expectWarning } = createdRequire(process.env.COMMON_DIRECTORY); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciexpectWarning('ExperimentalWarning', 91cb0ef41Sopenharmony_ci 'Single executable application is an experimental feature and ' + 101cb0ef41Sopenharmony_ci 'might change at any time'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci// Should be possible to require core modules that optionally require the 131cb0ef41Sopenharmony_ci// "node:" scheme. 141cb0ef41Sopenharmony_ciconst { deepStrictEqual, strictEqual, throws } = require('assert'); 151cb0ef41Sopenharmony_ciconst { dirname } = require('node:path'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci// Should be possible to require a core module that requires using the "node:" 181cb0ef41Sopenharmony_ci// scheme. 191cb0ef41Sopenharmony_ci{ 201cb0ef41Sopenharmony_ci const { test } = require('node:test'); 211cb0ef41Sopenharmony_ci strictEqual(typeof test, 'function'); 221cb0ef41Sopenharmony_ci} 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci// Should not be possible to require a core module without the "node:" scheme if 251cb0ef41Sopenharmony_ci// it requires using the "node:" scheme. 261cb0ef41Sopenharmony_cithrows(() => require('test'), { 271cb0ef41Sopenharmony_ci code: 'ERR_UNKNOWN_BUILTIN_MODULE', 281cb0ef41Sopenharmony_ci}); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_cideepStrictEqual(process.argv, [process.execPath, process.execPath, '-a', '--b=c', 'd']); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_cistrictEqual(require.cache, undefined); 331cb0ef41Sopenharmony_cistrictEqual(require.extensions, undefined); 341cb0ef41Sopenharmony_cistrictEqual(require.main, module); 351cb0ef41Sopenharmony_cistrictEqual(require.resolve, undefined); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_cistrictEqual(__filename, process.execPath); 381cb0ef41Sopenharmony_cistrictEqual(__dirname, dirname(process.execPath)); 391cb0ef41Sopenharmony_cistrictEqual(module.exports, exports); 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_cithrows(() => require('./requirable.js'), { 421cb0ef41Sopenharmony_ci code: 'ERR_UNKNOWN_BUILTIN_MODULE', 431cb0ef41Sopenharmony_ci}); 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ciconst requirable = createdRequire('./requirable.js'); 461cb0ef41Sopenharmony_cideepStrictEqual(requirable, { 471cb0ef41Sopenharmony_ci hello: 'world', 481cb0ef41Sopenharmony_ci}); 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ciconsole.log('Hello, world! '); 51