Skip to content

Commit

Permalink
New test to make sure module loading cleans up after itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Aug 8, 2011
1 parent 0acbb7f commit c105d4e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/moduleNamespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ asyncModuleTest("provide: still calls the callback even if one of the modules in
asyncModuleTest("provide: two calls in a row for a nonextant module still results in both callbacks being called", function (require, exports, module) {
var numberOfLoadsSoFar = 0;

module.provide(["asdf"], function onLoad1() {
module.provide(["asdf"], function onProvided1() {
ok(true, "First callback");

++numberOfLoadsSoFar;
Expand All @@ -140,7 +140,7 @@ asyncModuleTest("provide: two calls in a row for a nonextant module still result
}
});

module.provide(["asdf"], function onLoad2() {
module.provide(["asdf"], function onProvided2() {
ok(true, "Second callback");

++numberOfLoadsSoFar;
Expand All @@ -150,6 +150,20 @@ asyncModuleTest("provide: two calls in a row for a nonextant module still result
});
});

asyncModuleTest("provide: providing an extant module then a nonextant module does not mistakenly memoize the nonextant module using leftovers from the extant one", function (require, exports, module) {
module.provide(["demos/math"], function () {
ok(true, "Callback for extant module reached");
module.provide(["asdf"], function () {
ok(true, "Callback for nonextant module reached");

strictEqual(require.isMemoized("demos/math"), true, "The extant module is memoized");
strictEqual(require.isMemoized("asdf"), false, "The nonextant module is not memoized");

start();
});
});
});

// See http://groups.google.com/group/commonjs/browse_thread/thread/50d4565bd07e03cb
asyncModuleTest("provide: does not modify module.dependencies", function (require, exports, module) {
module.provide(["demos/restaurants"], function onModulesProvided() {
Expand Down

0 comments on commit c105d4e

Please sign in to comment.