use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.
the class UnitThrowAnalysisTest method testJDivExpr.
@Test
public void testJDivExpr() {
Set vmAndArithmetic = new ExceptionHashSet(utility.VM_ERRORS);
vmAndArithmetic.add(utility.ARITHMETIC_EXCEPTION);
Set vmAndArithmeticAndSupertypes = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
vmAndArithmeticAndSupertypes.add(utility.ARITHMETIC_EXCEPTION);
vmAndArithmeticAndSupertypes.add(utility.RUNTIME_EXCEPTION);
vmAndArithmeticAndSupertypes.add(utility.EXCEPTION);
Local intLocal = Jimple.v().newLocal("intLocal", IntType.v());
Local longLocal = Jimple.v().newLocal("longLocal", LongType.v());
Local floatLocal = Jimple.v().newLocal("floatLocal", FloatType.v());
Local doubleLocal = Jimple.v().newLocal("doubleLocal", DoubleType.v());
DivExpr v = Jimple.v().newDivExpr(intLocal, IntConstant.v(0));
assertTrue(ExceptionTestUtility.sameMembers(vmAndArithmetic, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(vmAndArithmeticAndSupertypes, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(intLocal, IntConstant.v(2));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(IntConstant.v(0), IntConstant.v(2));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(intLocal, intLocal);
assertTrue(ExceptionTestUtility.sameMembers(vmAndArithmetic, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(vmAndArithmeticAndSupertypes, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(longLocal, LongConstant.v(0));
assertTrue(ExceptionTestUtility.sameMembers(vmAndArithmetic, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(vmAndArithmeticAndSupertypes, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(longLocal, LongConstant.v(2));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(LongConstant.v(0), LongConstant.v(2));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(longLocal, longLocal);
assertTrue(ExceptionTestUtility.sameMembers(vmAndArithmetic, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(vmAndArithmeticAndSupertypes, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(floatLocal, FloatConstant.v(0.0f));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(floatLocal, FloatConstant.v(2.0f));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(FloatConstant.v(0), FloatConstant.v(2.0f));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(floatLocal, floatLocal);
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(doubleLocal, DoubleConstant.v(0.0));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(doubleLocal, DoubleConstant.v(2.0));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(DoubleConstant.v(0), DoubleConstant.v(2.0));
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
v = Jimple.v().newDivExpr(doubleLocal, doubleLocal);
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v)));
}
use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.
the class UnitThrowAnalysisTest method testBArrayLengthInst.
@Test
public void testBArrayLengthInst() {
soot.baf.ArrayLengthInst i = soot.baf.Baf.v().newArrayLengthInst();
Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
expectedRep.add(utility.NULL_POINTER_EXCEPTION);
assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(i)));
Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
expectedCatch.add(utility.RUNTIME_EXCEPTION);
expectedCatch.add(utility.EXCEPTION);
assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(i)));
}
use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.
the class UnitThrowAnalysisTest method testJReturnVoidStmt.
@Ignore("Fails")
@Test
public void testJReturnVoidStmt() {
Stmt s = Jimple.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 testGExitMonitorStmt.
@Test
public void testGExitMonitorStmt() {
Stmt s = Grimp.v().newExitMonitorStmt(StringConstant.v("test"));
Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
expectedRep.add(utility.NULL_POINTER_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.NULL_POINTER_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 testJNopStmt.
@Test
public void testJNopStmt() {
Stmt s = Jimple.v().newNopStmt();
Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
}
Aggregations