Permalink
Browse files

Tests for cache fixes.

  • Loading branch information...
1 parent b947329 commit 47532ca852ae385baca66e2c0f41cacd7149f4ce Mason Browne committed Mar 1, 2012
@@ -0,0 +1,6 @@
+requireCount = 0
+
+module.exports = {
+ count: (-> requireCount )
+ bump: (-> requireCount++)
+}
@@ -0,0 +1,6 @@
+requireCount = 0
+
+module.exports = {
+ count: (-> requireCount )
+ bump: (-> requireCount++)
+}
@@ -8,7 +8,7 @@ altFixtures = fixtureRoot + "/alternate"
addlFixtures = fixtureRoot + "/additional"
ecoFixtures = fixtureRoot + "/eco"
linkFixtures = fixtureRoot + "/link"
-fixtureCount = 17
+fixtureCount = 19
defaultOptions =
identifier: "testRequire"
@@ -209,6 +209,39 @@ module.exports =
test.same buz, "BUZ"
test.done()
+ "pulls module from cache": (test) ->
+ test.expect 5
+ defaultPackage.compile (err, sources) ->
+ test.ok !err
+ testRequire = load sources
+ faz = testRequire("foo/fuz/faz")
+ test.same 0, faz.count()
+ faz.bump()
+ test.same 1, faz.count()
+ # Reload
+ faz = testRequire("foo/fuz/faz")
+ test.same 1, faz.count()
+ faz.bump()
+ test.same 2, faz.count()
+ test.done()
+
+ "pulls module from cache when module index": (test) ->
+ test.expect 5
+ defaultPackage.compile (err, sources) ->
+ test.ok !err
+ testRequire = load sources
+ faz = testRequire("foo/fuz")
+ test.same 0, faz.count()
+ faz.bump()
+ test.same 1, faz.count()
+ # Reload
+ faz = testRequire("foo/fuz")
+ test.same 1, faz.count()
+ faz.bump()
+ test.same 2, faz.count()
+ test.done()
+
+
"modules can be defined at runtime": (test) ->
test.expect 3

0 comments on commit 47532ca

Please sign in to comment.