public static void verifyExceptionHandling(Class<? extends Throwable> exceptionClass, ExecutionNode node, MethodState mState) { verifyExceptionHandling(exceptionClass, null, node, mState); }
@Test public void integerDivisionByZeroExceptionIsCaughtAndHasNoChildrenAndAssignsNoRegisters() { int value1 = 10; int value2 = 0; VMTester.setRegisterMock(mState, ARG1_REGISTER, value1, "I"); buildInstruction22s(Opcode.DIV_INT_LIT16, value2); op = opFactory.create(location, addressToLocation, vm); op.execute(node, mState); VMTester.verifyExceptionHandling(ArithmeticException.class, "/ by zero", node, mState); }
@Test public void integerModuloByZeroExceptionIsCaughtAndHasNoChildrenAndAssignsNoRegisters() { int value1 = 10; int value2 = 0; VMTester.setRegisterMock(mState, ARG1_REGISTER, value1, "I"); buildInstruction22s(Opcode.REM_INT_LIT16, value2); op = opFactory.create(location, addressToLocation, vm); op.execute(node, mState); VMTester.verifyExceptionHandling(ArithmeticException.class, "/ by zero", node, mState); }
@Test public void longModuloByZeroExceptionIsCaughtAndHasNoChildrenAndAssignsNoRegisters() { long value1 = 1120403456L; long value2 = 0L; VMTester.setRegisterMock(mState, ARG1_REGISTER, value1, "J"); VMTester.setRegisterMock(mState, ARG2_REGISTER, value2, "J"); buildInstruction23x(Opcode.REM_LONG); op = opFactory.create(location, addressToLocation, vm); op.execute(node, mState); VMTester.verifyExceptionHandling(ArithmeticException.class, "/ by zero", node, mState); }
@Test public void longDivisionByZeroExceptionIsCaughtAndHasNoChildrenAndAssignsNoRegisters() { long value1 = 1120403456L; long value2 = 0L; VMTester.setRegisterMock(mState, ARG1_REGISTER, value1, "J"); VMTester.setRegisterMock(mState, ARG2_REGISTER, value2, "J"); buildInstruction23x(Opcode.DIV_LONG); op = opFactory.create(location, addressToLocation, vm); op.execute(node, mState); VMTester.verifyExceptionHandling(ArithmeticException.class, "/ by zero", node, mState); }