test/compiler/7052494/Test7052494.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7067288 Sdiff test/compiler/7052494

test/compiler/7052494/Test7052494.java

Print this page




  53     return result;
  54   }
  55 
  56   static void test3(int i, int limit, int arr[]) {
  57     while (i++ != 0) {
  58       if (arr[i-1] >= limit)
  59         break;
  60       arr[i] = i*2;
  61     }
  62   }
  63 
  64   static void test4(int i, int limit, int arr[]) {
  65     while (i-- != 0) {
  66       if (arr[arr.length + i + 1] <= limit)
  67         break;
  68       arr[arr.length + i] = i*2;
  69     }
  70   }
  71 
  72   // Empty loop rolls through MAXINT if i > 0



  73   static int test5(int i) {
  74     int result = 0;
  75     while (i++ != 0) {
  76       result = i*2;
  77     }
  78     return result;
  79   }
  80 
  81   // Empty loop rolls through MININT if i < 0



  82   static int test6(int i) {
  83     int result = 0;
  84     while (i-- != 0) {
  85       result = i*2;
  86     }
  87     return result;
  88   }
  89 
  90   public static void main(String [] args) {
  91     boolean failed = false;
  92     int[] arr = new int[8];
  93     int[] ar3 = { 0, 0, 4, 6, 8, 10, 0, 0 };
  94     int[] ar4 = { 0, 0, 0, -10, -8, -6, -4, 0 };

  95     for (int i = 0; i < 11000; i++) {
  96       int k = test1(1, 10);
  97       if (k != 10) {
  98         System.out.println("FAILED: " + k + " != 10");
  99         failed = true;
 100         break;
 101       }
 102     }

 103     for (int i = 0; i < 11000; i++) {
 104       int k = test2(-1, -10);
 105       if (k != -10) {
 106         System.out.println("FAILED: " + k + " != -10");
 107         failed = true;
 108         break;
 109       }
 110     }

 111     for (int i = 0; i < 11000; i++) {
 112       java.util.Arrays.fill(arr, 0);
 113       test3(1, 10, arr);
 114       if (!java.util.Arrays.equals(arr,ar3)) {
 115         System.out.println("FAILED: arr = { " + arr[0] + ", "
 116                                               + arr[1] + ", "
 117                                               + arr[2] + ", "
 118                                               + arr[3] + ", "
 119                                               + arr[4] + ", "
 120                                               + arr[5] + ", "
 121                                               + arr[6] + ", "
 122                                               + arr[7] + " }");
 123         failed = true;
 124         break;
 125       }
 126     }

 127     for (int i = 0; i < 11000; i++) {
 128       java.util.Arrays.fill(arr, 0);
 129       test4(-1, -10, arr);
 130       if (!java.util.Arrays.equals(arr,ar4)) {
 131         System.out.println("FAILED: arr = { " + arr[0] + ", "
 132                                               + arr[1] + ", "
 133                                               + arr[2] + ", "
 134                                               + arr[3] + ", "
 135                                               + arr[4] + ", "
 136                                               + arr[5] + ", "
 137                                               + arr[6] + ", "
 138                                               + arr[7] + " }");
 139         failed = true;
 140         break;
 141       }
 142     }

 143     for (int i = 0; i < 11000; i++) {
 144       int k = test5(1);
 145       if (k != 0) {
 146         System.out.println("FAILED: " + k + " != 0");
 147         failed = true;
 148         break;
 149       }
 150     }

 151     for (int i = 0; i < 11000; i++) {
 152       int k = test6(-1);
 153       if (k != 0) {
 154         System.out.println("FAILED: " + k + " != 0");
 155         failed = true;
 156         break;
 157       }
 158     }

 159     if (failed)
 160       System.exit(97);
 161   }
 162 }


  53     return result;
  54   }
  55 
  56   static void test3(int i, int limit, int arr[]) {
  57     while (i++ != 0) {
  58       if (arr[i-1] >= limit)
  59         break;
  60       arr[i] = i*2;
  61     }
  62   }
  63 
  64   static void test4(int i, int limit, int arr[]) {
  65     while (i-- != 0) {
  66       if (arr[arr.length + i + 1] <= limit)
  67         break;
  68       arr[arr.length + i] = i*2;
  69     }
  70   }
  71 
  72   // Empty loop rolls through MAXINT if i > 0
  73 
  74   static final int limit5 = Integer.MIN_VALUE + 10000;
  75 
  76   static int test5(int i) {
  77     int result = 0;
  78     while (i++ != limit5) {
  79       result = i*2;
  80     }
  81     return result;
  82   }
  83 
  84   // Empty loop rolls through MININT if i < 0
  85 
  86   static final int limit6 = Integer.MAX_VALUE - 10000;
  87 
  88   static int test6(int i) {
  89     int result = 0;
  90     while (i-- != limit6) {
  91       result = i*2;
  92     }
  93     return result;
  94   }
  95 
  96   public static void main(String [] args) {
  97     boolean failed = false;
  98     int[] arr = new int[8];
  99     int[] ar3 = { 0, 0, 4, 6, 8, 10, 0, 0 };
 100     int[] ar4 = { 0, 0, 0, -10, -8, -6, -4, 0 };
 101     System.out.println("test1");
 102     for (int i = 0; i < 11000; i++) {
 103       int k = test1(1, 10);
 104       if (k != 10) {
 105         System.out.println("FAILED: " + k + " != 10");
 106         failed = true;
 107         break;
 108       }
 109     }
 110     System.out.println("test2");
 111     for (int i = 0; i < 11000; i++) {
 112       int k = test2(-1, -10);
 113       if (k != -10) {
 114         System.out.println("FAILED: " + k + " != -10");
 115         failed = true;
 116         break;
 117       }
 118     }
 119     System.out.println("test3");
 120     for (int i = 0; i < 11000; i++) {
 121       java.util.Arrays.fill(arr, 0);
 122       test3(1, 10, arr);
 123       if (!java.util.Arrays.equals(arr,ar3)) {
 124         System.out.println("FAILED: arr = { " + arr[0] + ", "
 125                                               + arr[1] + ", "
 126                                               + arr[2] + ", "
 127                                               + arr[3] + ", "
 128                                               + arr[4] + ", "
 129                                               + arr[5] + ", "
 130                                               + arr[6] + ", "
 131                                               + arr[7] + " }");
 132         failed = true;
 133         break;
 134       }
 135     }
 136     System.out.println("test4");
 137     for (int i = 0; i < 11000; i++) {
 138       java.util.Arrays.fill(arr, 0);
 139       test4(-1, -10, arr);
 140       if (!java.util.Arrays.equals(arr,ar4)) {
 141         System.out.println("FAILED: arr = { " + arr[0] + ", "
 142                                               + arr[1] + ", "
 143                                               + arr[2] + ", "
 144                                               + arr[3] + ", "
 145                                               + arr[4] + ", "
 146                                               + arr[5] + ", "
 147                                               + arr[6] + ", "
 148                                               + arr[7] + " }");
 149         failed = true;
 150         break;
 151       }
 152     }
 153     System.out.println("test5");
 154     for (int i = 0; i < 11000; i++) {
 155       int k = test5(limit6);
 156       if (k != limit5*2) {
 157         System.out.println("FAILED: " + k + " != " + limit5*2);
 158         failed = true;
 159         break;
 160       }
 161     }
 162     System.out.println("test6");
 163     for (int i = 0; i < 11000; i++) {
 164       int k = test6(limit5);
 165       if (k != limit6*2) {
 166         System.out.println("FAILED: " + k + " != " + limit6*2);
 167         failed = true;
 168         break;
 169       }
 170     }
 171     System.out.println("finish");
 172     if (failed)
 173       System.exit(97);
 174   }
 175 }
test/compiler/7052494/Test7052494.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File