Home | History | Annotate | Download | only in 121-sccp
      1 class Blort {
      2 
      3     // Test integers
      4     public static int testIntAddSub() {
      5         int a, b, c, d;
      6         a = 3;
      7         b = 5 - a;
      8         while (true) {
      9             c = a + b;
     10             d = 5;
     11             a = d - b;
     12             if (c <= d) {
     13                 c = d + 1;
     14             } else {
     15                 return c;
     16             }
     17             b = 2;
     18         }
     19     }
     20 
     21     public static int testIntMult() {
     22         int a = 6;
     23         int b = 9 - a;
     24         int c = b * 4;
     25 
     26         if (c > 10) {
     27             c = c - 10;
     28         }
     29         return c * 2;
     30     }
     31 
     32     public static int testIntDiv() {
     33         int a = 30;
     34         int b = 9 - a / 5;
     35         int c = b * 4;
     36 
     37         if (c > 10) {
     38             c = c - 10;
     39         }
     40         return c * (60 / a);
     41     }
     42 
     43     public static int testIntMod() {
     44         int a = 5;
     45         int b = a % 3;
     46         int c = a % 0;
     47         return b + c;
     48     }
     49 
     50     public static int testIntPhi() {
     51         int a = 37;
     52         int b = 3;
     53         int c = (b == 0) ? 0 : (a / b);
     54         return c;
     55     }
     56 
     57     // Test floats
     58     public static float testFloatAddSub() {
     59         float a, b, c, d;
     60         a = 3;
     61         b = 5 - a;
     62         while (true) {
     63             c = a + b;
     64             d = 5;
     65             a = d - b;
     66             if (c <= d) {
     67                 c = d + 1;
     68             } else {
     69                 return c;
     70             }
     71             b = 2;
     72         }
     73     }
     74 
     75     public static float testFloatMult() {
     76         float a = 6;
     77         float b = 9 - a;
     78         float c = b * 4;
     79 
     80         if (c > 10) {
     81             c = c - 10;
     82         }
     83         return c * 2;
     84     }
     85 
     86     public static float testFloatDiv() {
     87         float a = 30;
     88         float b = 9 - a / 5;
     89         float c = b * 4;
     90 
     91         if (c > 10) {
     92             c = c - 10;
     93         }
     94         return c * (60 / a);
     95     }
     96 
     97     public static float testFloatMod() {
     98         float a = 5;
     99         float b = a % 3;
    100         float c = a % 0;
    101         return b + c;
    102     }
    103 
    104     public static float testFloatPhi() {
    105         float a = 37;
    106         float b = 3;
    107         float c = (b == 0) ? 0 : (a / b);
    108         return c;
    109     }
    110 
    111     // Test doubles
    112     public static double testDoubleAddSub() {
    113         double a, b, c, d;
    114         a = 3;
    115         b = 5 - a;
    116         while (true) {
    117             c = a + b;
    118             d = 5;
    119             a = d - b;
    120             if (c <= d) {
    121                 c = d + 1;
    122             } else {
    123                 return c;
    124             }
    125             b = 2;
    126         }
    127     }
    128 
    129     public static double testDoubleMult() {
    130         double a = 6;
    131         double b = 9 - a;
    132         double c = b * 4;
    133 
    134         if (c > 10) {
    135             c = c - 10;
    136         }
    137         return c * 2;
    138     }
    139 
    140     public static double testDoubleDiv() {
    141         double a = 30;
    142         double b = 9 - a / 5;
    143         double c = b * 4;
    144 
    145         if (c > 10) {
    146             c = c - 10;
    147         }
    148         return c * (60 / a);
    149     }
    150 
    151     public static double testDoubleMod() {
    152         double a = 5;
    153         double b = a % 3;
    154         double c = a % 0;
    155         return b + c;
    156     }
    157 
    158     public static double testDoublePhi() {
    159         double a = 37;
    160         double b = 3;
    161         double c = (b == 0) ? 0 : (a / b);
    162         return c;
    163     }
    164 }
    165