corda/sgx-jvm/avian/test/DivideByZero.java
Andras Slemmer 9bb3d6b972 Add 'sgx-jvm/avian/' from commit '09e4fe60d01f4f4bfb6b2976973bb4913ef61edc'
git-subtree-dir: sgx-jvm/avian
git-subtree-mainline: f978eab8d1
git-subtree-split: 09e4fe60d0
2017-03-13 12:18:24 +00:00

136 lines
2.5 KiB
Java

public class DivideByZero {
private static int divide(int n, int d) {
return n / d;
}
private static int modulo(int n, int d) {
return n % d;
}
private static long divide(long n, long d) {
return n / d;
}
private static long modulo(long n, long d) {
return n % d;
}
private static float divide(float n, float d) {
return n / d;
}
private static float modulo(float n, float d) {
return n % d;
}
private static double divide(double n, double d) {
return n / d;
}
private static double modulo(double n, double d) {
return n % d;
}
public static void main(String[] args) {
try {
int x = 1 / 0;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
int x = 1 % 0;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
int y = 2;
int x = y / 0;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
int y = 2;
int x = y % 0;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
int z = 0;
int y = 2;
int x = y / z;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
int z = 0;
int y = 2;
int x = y % z;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
long z = 0;
long y = 2;
long x = y / z;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
long z = 0;
long y = 2;
long x = y % z;
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
divide(5, 0);
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
modulo(6, 0);
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
divide(5L, 0L);
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
try {
modulo(6L, 0L);
throw new RuntimeException();
} catch (ArithmeticException e) {
e.printStackTrace();
}
divide(5F, 0F);
modulo(6F, 0F);
divide(5D, 0D);
modulo(6D, 0D);
}
}