2009-10-31 19:02:30 +01:00
|
|
|
process.mixin(require("./common"));
|
2009-09-28 12:06:30 +02:00
|
|
|
|
|
|
|
debug("load test-module-loading.js");
|
|
|
|
|
2009-10-31 19:02:30 +01:00
|
|
|
var a = require("./fixtures/a");
|
|
|
|
var d = require("./fixtures/b/d");
|
|
|
|
var d2 = require("./fixtures/b/d");
|
2009-11-02 21:21:02 +01:00
|
|
|
// Absolute
|
2009-11-02 00:34:16 +01:00
|
|
|
var d3 = require(require('path').dirname(__filename)+"/fixtures/b/d");
|
2009-11-02 21:21:02 +01:00
|
|
|
// Relative
|
|
|
|
var d4 = require("../mjsunit/fixtures/b/d");
|
2009-06-08 15:30:10 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(false, false, "testing the test program.");
|
2009-06-08 15:30:10 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, a.A instanceof Function);
|
|
|
|
assert.equal("A", a.A());
|
2009-06-08 15:30:10 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, a.C instanceof Function);
|
|
|
|
assert.equal("C", a.C());
|
2009-06-08 15:30:10 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, a.D instanceof Function);
|
|
|
|
assert.equal("D", a.D());
|
2009-06-08 15:30:10 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, d.D instanceof Function);
|
|
|
|
assert.equal("D", d.D());
|
2009-06-08 15:30:10 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, d2.D instanceof Function);
|
|
|
|
assert.equal("D", d2.D());
|
2009-06-08 16:17:33 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, d3.D instanceof Function);
|
|
|
|
assert.equal("D", d3.D());
|
2009-11-02 00:34:16 +01:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, d4.D instanceof Function);
|
|
|
|
assert.equal("D", d4.D());
|
2009-11-02 21:21:02 +01:00
|
|
|
|
2009-12-22 16:24:32 +01:00
|
|
|
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.foo, foo);
|
|
|
|
assert.equal(root.sayHello(), root.hello);
|
|
|
|
|
2009-12-18 23:58:04 +01:00
|
|
|
var errorThrown = false;
|
|
|
|
try {
|
|
|
|
require("./fixtures/throws_error");
|
|
|
|
} catch (e) {
|
|
|
|
errorThrown = true;
|
|
|
|
assert.equal("blah", e.message);
|
|
|
|
}
|
|
|
|
|
2009-08-26 18:51:04 +02:00
|
|
|
process.addListener("exit", function () {
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, a.A instanceof Function);
|
|
|
|
assert.equal("A done", a.A());
|
2009-06-08 16:17:33 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, a.C instanceof Function);
|
|
|
|
assert.equal("C done", a.C());
|
2009-06-08 16:17:33 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, a.D instanceof Function);
|
|
|
|
assert.equal("D done", a.D());
|
2009-06-08 16:17:33 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, d.D instanceof Function);
|
|
|
|
assert.equal("D done", d.D());
|
2009-06-08 16:17:33 +02:00
|
|
|
|
2009-11-28 18:26:59 +01:00
|
|
|
assert.equal(true, d2.D instanceof Function);
|
|
|
|
assert.equal("D done", d2.D());
|
2009-09-18 15:45:47 +02:00
|
|
|
|
2009-12-18 23:58:04 +01:00
|
|
|
assert.equal(true, errorThrown);
|
|
|
|
|
2009-09-18 15:45:47 +02:00
|
|
|
puts("exit");
|
2009-08-26 18:51:04 +02:00
|
|
|
});
|