Last active
March 3, 2017 14:26
-
-
Save aliaspooryorik/a1fef76331002e94a3306db845500720 to your computer and use it in GitHub Desktop.
Find bleeding variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component extends="testbox.system.BaseSpec" { | |
function run(testResults, testBox) { | |
it ("should not bleed variables", function() { | |
prepareMock(variables.sut).$property("getVariablesScopeList", "this", getVariablesScopeList); | |
var before = sut.getVariablesScopeList(); | |
sut.doSomething(); | |
var after = sut.getVariablesScopeList(); | |
expect(before).toBe(after, "variables have leaked!"); | |
}); | |
} | |
private string function getVariablesScopeList() { | |
return structKeyList(variables); | |
}; | |
} | |
// my sut | |
component { | |
void function doSomething() { | |
var a = 1; | |
b = 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment