Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

index.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 'use strict';
  2. var test = require('tape');
  3. var keys = require('object-keys');
  4. var isCore = require('../');
  5. var data = require('../core.json');
  6. test('core modules', function (t) {
  7. t.test('isCore()', function (st) {
  8. st.ok(isCore('fs'));
  9. st.ok(isCore('net'));
  10. st.ok(isCore('http'));
  11. st.ok(!isCore('seq'));
  12. st.ok(!isCore('../'));
  13. st.ok(!isCore('toString'));
  14. st.end();
  15. });
  16. t.test('core list', function (st) {
  17. var cores = keys(data);
  18. st.plan(cores.length);
  19. for (var i = 0; i < cores.length; ++i) {
  20. var mod = cores[i];
  21. var requireFunc = function () { require(mod); }; // eslint-disable-line no-loop-func
  22. if (isCore(mod)) {
  23. st.doesNotThrow(requireFunc, mod + ' supported; requiring does not throw');
  24. } else {
  25. st['throws'](requireFunc, mod + ' not supported; requiring throws');
  26. }
  27. }
  28. st.end();
  29. });
  30. t.test('core via repl module', { skip: !data.repl }, function (st) {
  31. var libs = require('repl')._builtinLibs; // eslint-disable-line no-underscore-dangle
  32. if (!libs) {
  33. st.skip('module.builtinModules does not exist');
  34. } else {
  35. for (var i = 0; i < libs.length; ++i) {
  36. var mod = libs[i];
  37. st.ok(data[mod], mod + ' is a core module');
  38. st.doesNotThrow(
  39. function () { require(mod); }, // eslint-disable-line no-loop-func
  40. 'requiring ' + mod + ' does not throw'
  41. );
  42. }
  43. }
  44. st.end();
  45. });
  46. t.test('core via builtinModules list', { skip: !data.module }, function (st) {
  47. var libs = require('module').builtinModules;
  48. if (!libs) {
  49. st.skip('module.builtinModules does not exist');
  50. } else {
  51. var excludeList = [
  52. '_debug_agent',
  53. 'v8/tools/tickprocessor-driver',
  54. 'v8/tools/SourceMap',
  55. 'v8/tools/tickprocessor',
  56. 'v8/tools/profile'
  57. ];
  58. for (var i = 0; i < libs.length; ++i) {
  59. var mod = libs[i];
  60. if (excludeList.indexOf(mod) === -1) {
  61. st.ok(data[mod], mod + ' is a core module');
  62. st.doesNotThrow(
  63. function () { require(mod); }, // eslint-disable-line no-loop-func
  64. 'requiring ' + mod + ' does not throw'
  65. );
  66. }
  67. }
  68. }
  69. st.end();
  70. });
  71. t.end();
  72. });