From c105d4e069707b1c3dfe3567a5cffd22508a5e69 Mon Sep 17 00:00:00 2001 From: DomenicDenicola Date: Mon, 8 Aug 2011 16:07:38 -0400 Subject: [PATCH] New test to make sure module loading cleans up after itself. --- test/moduleNamespace.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/moduleNamespace.js b/test/moduleNamespace.js index 8fcb6b2..1c1c996 100644 --- a/test/moduleNamespace.js +++ b/test/moduleNamespace.js @@ -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; @@ -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; @@ -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() {