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)));
}
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)));
}
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)));
}
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)));
}
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)));
}
Aggregations