mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.1 KiB
85 lines
2.1 KiB
15 years ago
|
process.mixin(require("../common"));
|
||
15 years ago
|
|
||
|
debug("load test-module-loading.js");
|
||
|
|
||
15 years ago
|
var a = require("../fixtures/a");
|
||
|
var c = require("../fixtures/b/c");
|
||
|
var d = require("../fixtures/b/d");
|
||
|
var d2 = require("../fixtures/b/d");
|
||
15 years ago
|
// Absolute
|
||
15 years ago
|
var d3 = require(path.join(__dirname, "../fixtures/b/d"));
|
||
15 years ago
|
// Relative
|
||
15 years ago
|
var d4 = require("../fixtures/b/d");
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(false, false, "testing the test program.");
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, a.A instanceof Function);
|
||
|
assert.equal("A", a.A());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, a.C instanceof Function);
|
||
|
assert.equal("C", a.C());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, a.D instanceof Function);
|
||
|
assert.equal("D", a.D());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, d.D instanceof Function);
|
||
|
assert.equal("D", d.D());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, d2.D instanceof Function);
|
||
|
assert.equal("D", d2.D());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, d3.D instanceof Function);
|
||
|
assert.equal("D", d3.D());
|
||
15 years ago
|
|
||
15 years ago
|
assert.equal(true, d4.D instanceof Function);
|
||
|
assert.equal("D", d4.D());
|
||
15 years ago
|
|
||
15 years ago
|
assert.ok((new a.SomeClass) instanceof c.SomeClass);
|
||
|
|
||
15 years ago
|
debug("test index.js modules ids and relative loading")
|
||
15 years ago
|
var one = require("../fixtures/nested-index/one"),
|
||
|
two = require("../fixtures/nested-index/two");
|
||
15 years ago
|
assert.notEqual(one.hello, two.hello);
|
||
|
|
||
|
debug("test cycles containing a .. path");
|
||
15 years ago
|
var root = require("../fixtures/cycles/root"),
|
||
|
foo = require("../fixtures/cycles/folder/foo");
|
||
15 years ago
|
assert.equal(root.foo, foo);
|
||
15 years ago
|
assert.equal(root.sayHello(), root.hello);
|
||
|
|
||
15 years ago
|
var errorThrown = false;
|
||
|
try {
|
||
15 years ago
|
require("../fixtures/throws_error");
|
||
15 years ago
|
} catch (e) {
|
||
|
errorThrown = true;
|
||
|
assert.equal("blah", e.message);
|
||
|
}
|
||
|
|
||
15 years ago
|
assert.equal(require('path').dirname(__filename), __dirname);
|
||
|
|
||
15 years ago
|
require.async('../fixtures/a', function (err, a) {
|
||
15 years ago
|
if (err) throw err;
|
||
|
assert.equal("A", a.A());
|
||
|
});
|
||
15 years ago
|
|
||
16 years ago
|
process.addListener("exit", function () {
|
||
15 years ago
|
assert.equal(true, a.A instanceof Function);
|
||
|
assert.equal("A done", a.A());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, a.C instanceof Function);
|
||
|
assert.equal("C done", a.C());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, a.D instanceof Function);
|
||
|
assert.equal("D done", a.D());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, d.D instanceof Function);
|
||
|
assert.equal("D done", d.D());
|
||
16 years ago
|
|
||
15 years ago
|
assert.equal(true, d2.D instanceof Function);
|
||
|
assert.equal("D done", d2.D());
|
||
15 years ago
|
|
||
15 years ago
|
assert.equal(true, errorThrown);
|
||
|
|
||
15 years ago
|
puts("exit");
|
||
16 years ago
|
});
|