diff --git a/test/index.js b/test/index.js index 9b35bc9..746e72a 100644 --- a/test/index.js +++ b/test/index.js @@ -72,7 +72,8 @@ test('core modules', function (t) { }); t.test('core via builtinModules list', { skip: !data.module }, function (st) { - var libs = require('module').builtinModules; + var Module = require('module'); + var libs = Module.builtinModules; if (!libs) { st.skip('module.builtinModules does not exist'); } else { @@ -96,10 +97,24 @@ test('core modules', function (t) { var mod = libs[i]; if (excludeList.indexOf(mod) === -1) { st.ok(data[mod], mod + ' is a core module'); + + if (Module.isBuiltin) { + st.ok(Module.isBuiltin(mod), 'module.isBuiltin(' + mod + ') is true'); + } + st.doesNotThrow( function () { require(mod); }, // eslint-disable-line no-loop-func 'requiring ' + mod + ' does not throw' ); + + if (process.getBuiltinModule) { + st.equal( + process.getBuiltinModule(mod), + require(mod), + 'process.getBuiltinModule(' + mod + ') === require(' + mod + ')' + ); + } + if (mod.slice(0, 5) !== 'node:') { if (supportsNodePrefix) { st.doesNotThrow( @@ -116,6 +131,7 @@ test('core modules', function (t) { } } } + st.end(); });