This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
/
test-module-loading.js
84 lines (61 loc) · 2.12 KB
/
test-module-loading.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
process.mixin(require("./common"));
debug("load test-module-loading.js");
var a = require("./fixtures/a");
var c = require("./fixtures/b/c");
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());
assert.ok((new a.SomeClass) instanceof c.SomeClass);
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);
var errorThrown = false;
try {
require("./fixtures/throws_error");
} catch (e) {
errorThrown = true;
assert.equal("blah", e.message);
}
assert.equal(require('path').dirname(__filename), __dirname);
require.async('./fixtures/a', function (err, a) {
if (err) throw err;
assert.equal("A", a.A());
});
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");
});