Skip to content

Instantly share code, notes, and snippets.

@aliaspooryorik
Last active March 3, 2017 14:26
Show Gist options
  • Save aliaspooryorik/a1fef76331002e94a3306db845500720 to your computer and use it in GitHub Desktop.
Save aliaspooryorik/a1fef76331002e94a3306db845500720 to your computer and use it in GitHub Desktop.
Find bleeding variables
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