purity inference: take into account constructor calls

This commit is contained in:
peter
2014-09-24 14:19:52 +02:00
parent 2b65ab7ef2
commit 56f6a73de7
2 changed files with 20 additions and 4 deletions
@@ -136,6 +136,20 @@ public Foo() {
"""
}
public void "test calling constructor with side effects"() {
assertPure false, """
Object newExample() {
return new Example1();
}
private int created = 0;
Example1() {
created++;
}
"""
}
private void assertPure(boolean expected, String classBody) {
def clazz = myFixture.addClass("final class Foo { $classBody }")
assert expected == PurityInference.inferPurity(clazz.methods[0])