mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
include() should not be used by libraries because it will pollute the global
namespace. To discourage this behavior and bring Node more in-line with
the current CommonJS module system, include() is removed.
Small scripts like unit tests often times do want to pollute the global
namespace for ease. To avoid the boiler plate code of
var x = require("/x.js");
var foo = x.foo;
var bar = x.bar;
The function node.mixin() is stolen from jQuery's jQuery.extend. So that it
can be written:
node.mixin(require("/x.js"));
Reference:
http://docs.jquery.com/Utilities/jQuery.extend
http://groups.google.com/group/nodejs/browse_thread/thread/f9ac83e5c11e7e87
44 lines
943 B
JavaScript
44 lines
943 B
JavaScript
node.mixin(require("common.js"));
|
|
|
|
debug("load test-module-loading.js");
|
|
|
|
var a = require("fixtures/a.js");
|
|
var d = require("fixtures/b/d.js");
|
|
var d2 = require("fixtures/b/d.js");
|
|
|
|
assertFalse(false, "testing the test program.");
|
|
|
|
assertInstanceof(a.A, Function);
|
|
assertEquals("A", a.A());
|
|
|
|
assertInstanceof(a.C, Function);
|
|
assertEquals("C", a.C());
|
|
|
|
assertInstanceof(a.D, Function);
|
|
assertEquals("D", a.D());
|
|
|
|
assertInstanceof(d.D, Function);
|
|
assertEquals("D", d.D());
|
|
|
|
assertInstanceof(d2.D, Function);
|
|
assertEquals("D", d2.D());
|
|
|
|
process.addListener("exit", function () {
|
|
assertInstanceof(a.A, Function);
|
|
assertEquals("A done", a.A());
|
|
|
|
assertInstanceof(a.C, Function);
|
|
assertEquals("C done", a.C());
|
|
|
|
assertInstanceof(a.D, Function);
|
|
assertEquals("D done", a.D());
|
|
|
|
assertInstanceof(d.D, Function);
|
|
assertEquals("D done", d.D());
|
|
|
|
assertInstanceof(d2.D, Function);
|
|
assertEquals("D done", d2.D());
|
|
|
|
puts("exit");
|
|
});
|