Merge pull request #59 from cos/ssa-equals-based-on-id
`SSAInstruction` equals based on its `iindex`
This commit is contained in:
commit
4a67dacfd8
@ -128,6 +128,22 @@ public class CFGTest extends WalaTestCase {
|
||||
doMethod("java.io.ObjectInputStream.resolveProxyClass([Ljava/lang/String;)Ljava/lang/Class;");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIRCacheIdempotence() {
|
||||
MethodReference mr = StringStuff.makeMethodReference("hello.Hello.main([Ljava/lang/String;)V");
|
||||
|
||||
IMethod m = cha.resolveMethod(mr);
|
||||
AnalysisCache cache = new AnalysisCache();
|
||||
IR irBefore = cache.getIR(m);
|
||||
cache.getSSACache().wipe();
|
||||
IR irAfter = cache.getIR(m);
|
||||
for (int i = 0; i < irBefore.getInstructions().length; i++) {
|
||||
System.out.println(irBefore.getInstructions()[i]);
|
||||
System.out.println(irAfter.getInstructions()[i]);
|
||||
Assert.assertEquals(irAfter.getInstructions()[i], irBefore.getInstructions()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSync1() {
|
||||
MethodReference mr = StringStuff.makeMethodReference("cfg.MonitorTest.sync1()V");
|
||||
|
||||
@ -290,6 +290,11 @@ public abstract class SSAInstruction {
|
||||
*/
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj != null && obj instanceof SSAInstruction)
|
||||
return this.iindex == ((SSAInstruction) obj).iindex;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user