Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #2008 Expose and test NativeModule.require

  • Loading branch information...
commit 6974d7b0ac5c40b22a843c227dab51c5bbcfc23a 1 parent 5b43c63
@isaacs authored
Showing with 13 additions and 1 deletion.
  1. +2 −1  src/node.js
  2. +11 −0 test/simple/test-module-loading.js
View
3  src/node.js
@@ -548,7 +548,8 @@
}
NativeModule.exists = function(id) {
- return NativeModule._source.hasOwnProperty(id);
+ return id === 'native_module' ||
+ NativeModule._source.hasOwnProperty(id);
}
NativeModule.getSource = function(id) {
View
11 test/simple/test-module-loading.js
@@ -269,6 +269,17 @@ assert.deepEqual(children, {
});
+// #2008 Loading NativeModule
+// It's somewhat internal, but should still behave properly,
+// since it is exposted.
+common.debug('testing native_module usage to load all natives');
+var NativeModule = require('native_module');
+assert.equal(NativeModule, NativeModule.require('native_module'));
+assert.equal(typeof NativeModule._source, 'object');
+Object.keys(NativeModule._source).forEach(function (mod) {
+ assert.equal(require(mod), NativeModule.require(mod));
+});
+
process.on('exit', function() {
assert.ok(common.indirectInstanceOf(a.A, Function));
assert.equal('A done', a.A());
Please sign in to comment.
Something went wrong with that request. Please try again.