Skip to content
Browse files

Test for global leakage

  • Loading branch information...
1 parent c2de1fa commit 810b42c1b95c398a7342cc3a1e2c9ab96fbbec6b @isaacs committed Dec 16, 2011
Showing with 11 additions and 3 deletions.
  1. +11 −3 test/index.js
View
14 test/index.js
@@ -1,5 +1,5 @@
-
-var util = require("util")
+var globalsBefore = JSON.stringify(Object.keys(global))
+ , util = require("util")
, assert = require("assert")
, fs = require("fs")
, path = require("path")
@@ -47,7 +47,7 @@ exports.test = function test (options) {
if (module === require.main) {
var running = true
- , failures = 0
+ , failures = 0
function fail (file, er) {
util.error("Failed: "+file)
@@ -66,6 +66,14 @@ if (module === require.main) {
// run this test.
try {
require(path.resolve(__dirname, file))
+ var globalsAfter = JSON.stringify(Object.keys(global))
+ if (globalsAfter !== globalsBefore) {
+ var er = new Error("new globals introduced\n"+
+ "expected: "+globalsBefore+"\n"+
+ "actual: "+globalsAfter)
+ globalsBefore = globalsAfter
+ throw er
+ }
console.log("ok " + (++i) + " - " + file)
} catch (er) {
console.log("not ok "+ (++i) + " - " + file)

0 comments on commit 810b42c

Please sign in to comment.
Something went wrong with that request. Please try again.