Search in sources :

Example 21 with ExceptionHashSet

use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.

the class UnitThrowAnalysisTest method testGInvokeStmt.

@Ignore("Fails")
@Test
public void testGInvokeStmt() {
    List voidList = new ArrayList();
    Stmt s = Grimp.v().newInvokeStmt(Grimp.v().newVirtualInvokeExpr(Grimp.v().newLocal("local1", RefType.v("java.lang.Object")), Scene.v().makeMethodRef(Scene.v().getSootClass("java.lang.Object"), "wait", voidList, VoidType.v(), false), voidList));
    ExceptionHashSet expectedRep = new ExceptionHashSet(utility.VM_AND_RESOLVE_METHOD_ERRORS_REP);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    ExceptionHashSet expectedCatch = new ExceptionHashSet(utility.VM_AND_RESOLVE_METHOD_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, immaculateAnalysis.mightThrow(s)));
    assertEquals(expectedCatch, utility.catchableSubset(immaculateAnalysis.mightThrow(s)));
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_THROWABLES_REP, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    assertEquals(utility.ALL_TEST_THROWABLES, utility.catchableSubset(unitAnalysis.mightThrow(s)));
    SootClass bogusClass = new SootClass("BogusClass");
    bogusClass.addMethod(Scene.v().makeSootMethod("emptyMethod", voidList, VoidType.v(), Modifier.STATIC));
    s = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(Scene.v().makeMethodRef(bogusClass, "emptyMethod", voidList, VoidType.v(), true), voidList));
    s = Grimp.v().newInvokeStmt(Grimp.v().newStaticInvokeExpr(Scene.v().makeMethodRef(bogusClass, "emptyMethod", voidList, VoidType.v(), true), voidList));
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_ERRORS_REP, Collections.EMPTY_SET, immaculateAnalysis.mightThrow(s)));
    assertEquals(utility.ALL_TEST_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(immaculateAnalysis.mightThrow(s)));
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_THROWABLES_REP, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    assertEquals(utility.ALL_TEST_THROWABLES, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
Also used : ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SootClass(soot.SootClass) ThrowStmt(soot.jimple.ThrowStmt) IfStmt(soot.jimple.IfStmt) Stmt(soot.jimple.Stmt) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 22 with ExceptionHashSet

use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.

the class UnitThrowAnalysisTest method testGReturnVoidStmt.

@Ignore("Fails")
@Test
public void testGReturnVoidStmt() {
    Stmt s = Grimp.v().newReturnVoidStmt();
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
Also used : ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) Set(java.util.Set) ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) ThrowStmt(soot.jimple.ThrowStmt) IfStmt(soot.jimple.IfStmt) Stmt(soot.jimple.Stmt) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with ExceptionHashSet

use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.

the class UnitThrowAnalysisTest method testGBinOpExp.

@Ignore("Fails")
@Test
public void testGBinOpExp() {
    Value v = Grimp.v().newAddExpr(floatStaticFieldRef, floatConstant);
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_ERRORS_REP, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
    assertEquals(utility.ALL_TEST_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
    v = Grimp.v().newOrExpr(v, floatConstant);
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_ERRORS_REP, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
    assertEquals(utility.ALL_TEST_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
    Set expectedRep = new ExceptionHashSet(utility.ALL_ERRORS_REP);
    expectedRep.add(utility.NULL_POINTER_EXCEPTION);
    Set expectedCatch = new ExceptionHashSet(utility.ALL_TEST_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    v = Grimp.v().newLeExpr(floatInstanceFieldRef, v);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(v)));
    v = Grimp.v().newEqExpr(v, floatVirtualInvoke);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, immaculateAnalysis.mightThrow(v)));
    assertEquals(expectedCatch, utility.catchableSubset(immaculateAnalysis.mightThrow(v)));
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_THROWABLES_REP, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
    assertEquals(utility.ALL_TEST_THROWABLES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
    expectedRep.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
    expectedCatch.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
    expectedCatch.add(utility.INDEX_OUT_OF_BOUNDS_EXCEPTION);
    v = Grimp.v().newNeExpr(v, floatStaticInvoke);
    assertEquals(expectedCatch, utility.catchableSubset(immaculateAnalysis.mightThrow(v)));
    assertEquals(expectedCatch, utility.catchableSubset(immaculateAnalysis.mightThrow(v)));
    assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_THROWABLES_REP, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
    assertEquals(utility.ALL_TEST_THROWABLES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
}
Also used : ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) Set(java.util.Set) ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) Value(soot.Value) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with ExceptionHashSet

use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.

the class UnitThrowAnalysisTest method testJReturnStmt.

@Ignore("Fails")
@Test
public void testJReturnStmt() {
    Stmt s = Jimple.v().newReturnStmt(IntConstant.v(1));
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
    Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
    expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
    expectedCatch.add(utility.RUNTIME_EXCEPTION);
    expectedCatch.add(utility.EXCEPTION);
    assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
Also used : ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) Set(java.util.Set) ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) ThrowStmt(soot.jimple.ThrowStmt) IfStmt(soot.jimple.IfStmt) Stmt(soot.jimple.Stmt) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 25 with ExceptionHashSet

use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.

the class UnitThrowAnalysisTest method testGNopStmt.

@Test
public void testGNopStmt() {
    Stmt s = Grimp.v().newNopStmt();
    Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
    assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
}
Also used : ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) Set(java.util.Set) ExceptionHashSet(soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet) ThrowStmt(soot.jimple.ThrowStmt) IfStmt(soot.jimple.IfStmt) Stmt(soot.jimple.Stmt) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)27 ExceptionHashSet (soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet)27 Set (java.util.Set)25 ThrowStmt (soot.jimple.ThrowStmt)16 IfStmt (soot.jimple.IfStmt)14 Stmt (soot.jimple.Stmt)14 Local (soot.Local)9 Ignore (org.junit.Ignore)7 Value (soot.Value)4 ArrayRef (soot.jimple.ArrayRef)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 SootClass (soot.SootClass)2 DivExpr (soot.jimple.DivExpr)2 RemExpr (soot.jimple.RemExpr)2 AnySubType (soot.AnySubType)1 RefLikeType (soot.RefLikeType)1