You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AfterTest.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package test4;
  2. public class AfterTest {
  3. public void print() { System.out.println("test4.AfterTest"); }
  4. public int test1() { return m1(10) + m1(-10); }
  5. public int m1(int i) {
  6. if (i > 0)
  7. i = i + 10;
  8. else
  9. return -i;
  10. i = i + 100;
  11. return i + 1;
  12. }
  13. public int test2() throws Exception { return m2(1); }
  14. public int m2(int i) throws Exception {
  15. if (i > 10)
  16. throw new Exception();
  17. else if (i > 0)
  18. i = i + 10;
  19. else
  20. return -i;
  21. i = i + 100;
  22. return i + 1;
  23. }
  24. public int test3() throws Exception { return m3(-10); }
  25. public int m3(int i) throws Exception {
  26. if (i > 10)
  27. throw new Exception();
  28. else if (i > 0)
  29. i = i + 10;
  30. else
  31. return -i;
  32. i = i + 100;
  33. throw new Exception();
  34. }
  35. public int test4() throws Exception {
  36. try {
  37. return m4(-10);
  38. }
  39. catch (Exception e) {
  40. return 100;
  41. }
  42. }
  43. public int m4(int i) throws Exception {
  44. if (i > 0)
  45. i = i + 10;
  46. i = i + 100;
  47. throw new Exception();
  48. }
  49. public int test11() { return mm1(10) + mm1(-10); }
  50. public int mm1(int i) {
  51. if (i > 0)
  52. i = i + 10;
  53. else
  54. return -i;
  55. i = i + 100;
  56. return i + 1;
  57. }
  58. public int test22() throws Exception { return mm2(1); }
  59. public int mm2(int i) throws Exception {
  60. if (i > 10)
  61. throw new Exception();
  62. else if (i > 0)
  63. i = i + 10;
  64. else
  65. return -i;
  66. i = i + 100;
  67. return i + 1;
  68. }
  69. public int test33() throws Exception { return mm3(-10); }
  70. public int mm3(int i) throws Exception {
  71. if (i > 10)
  72. throw new Exception();
  73. else if (i > 0)
  74. i = i + 10;
  75. else
  76. return -i;
  77. i = i + 100;
  78. throw new Exception();
  79. }
  80. public int test44() throws Exception {
  81. try {
  82. return mm4(-10);
  83. }
  84. catch (Exception e) {
  85. return 100;
  86. }
  87. }
  88. public int mm4(int i) throws Exception {
  89. if (i > 0)
  90. i = i + 10;
  91. i = i + 100;
  92. throw new Exception();
  93. }
  94. }