mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
createModule got removed as it was unnecessary and caused issues by
doing its own cache checks independent of loadModule. Internal modules
are now the only globally cached modules, all other modules are only
cached by inheriting their parent modules cache.
Credits: Module specific cache and a few other diffs by Blaine Cook
431662d25c
http://romeda.org/blog/2010/01/hot-code-loading-in-nodejs.html
http://thread.gmane.org/gmane.comp.lang.javascript.nodejs/1994
76 lines
1.9 KiB
JavaScript
76 lines
1.9 KiB
JavaScript
process.mixin(require("./common"));
|
|
|
|
debug("load test-module-loading.js");
|
|
|
|
var a = require("./fixtures/a");
|
|
var d = require("./fixtures/b/d");
|
|
var d2 = require("./fixtures/b/d");
|
|
// Absolute
|
|
var d3 = require(__dirname+"/fixtures/b/d");
|
|
// Relative
|
|
var d4 = require("../mjsunit/fixtures/b/d");
|
|
|
|
assert.equal(false, false, "testing the test program.");
|
|
|
|
assert.equal(true, a.A instanceof Function);
|
|
assert.equal("A", a.A());
|
|
|
|
assert.equal(true, a.C instanceof Function);
|
|
assert.equal("C", a.C());
|
|
|
|
assert.equal(true, a.D instanceof Function);
|
|
assert.equal("D", a.D());
|
|
|
|
assert.equal(true, d.D instanceof Function);
|
|
assert.equal("D", d.D());
|
|
|
|
assert.equal(true, d2.D instanceof Function);
|
|
assert.equal("D", d2.D());
|
|
|
|
assert.equal(true, d3.D instanceof Function);
|
|
assert.equal("D", d3.D());
|
|
|
|
assert.equal(true, d4.D instanceof Function);
|
|
assert.equal("D", d4.D());
|
|
|
|
debug("test index.js modules ids and relative loading")
|
|
var one = require("./fixtures/nested-index/one"),
|
|
two = require("./fixtures/nested-index/two");
|
|
assert.notEqual(one.hello, two.hello);
|
|
|
|
debug("test cycles containing a .. path");
|
|
var root = require("./fixtures/cycles/root"),
|
|
foo = require("./fixtures/cycles/folder/foo");
|
|
assert.equal(root.sayHello(), root.hello);
|
|
|
|
var errorThrown = false;
|
|
try {
|
|
require("./fixtures/throws_error");
|
|
} catch (e) {
|
|
errorThrown = true;
|
|
assert.equal("blah", e.message);
|
|
}
|
|
|
|
assert.equal(require('path').dirname(__filename), __dirname);
|
|
|
|
process.addListener("exit", function () {
|
|
assert.equal(true, a.A instanceof Function);
|
|
assert.equal("A done", a.A());
|
|
|
|
assert.equal(true, a.C instanceof Function);
|
|
assert.equal("C done", a.C());
|
|
|
|
assert.equal(true, a.D instanceof Function);
|
|
assert.equal("D done", a.D());
|
|
|
|
assert.equal(true, d.D instanceof Function);
|
|
assert.equal("D done", d.D());
|
|
|
|
assert.equal(true, d2.D instanceof Function);
|
|
assert.equal("D done", d2.D());
|
|
|
|
assert.equal(true, errorThrown);
|
|
|
|
puts("exit");
|
|
});
|