boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

002-arith.c (883B)


      1 /* tests/cc-e2e/02-arith.c — basic arithmetic operators.
      2  * Split from 01-kitchen-sink. */
      3 
      4 int test_arith(void) {
      5     int a = 5;
      6     int b = 3;
      7     int r = 0;
      8     r = r + (a + b);                /* 8  */
      9     r = r + (a - b);                /* 2  */
     10     r = r + (a * b);                /* 15 */
     11     r = r + (10 / 3);               /* 3  */
     12     r = r + (10 % 3);               /* 1  */
     13     r = r + (1 << 4);               /* 16 */
     14     r = r + (64 >> 2);              /* 16 */
     15     r = r + (12 & 10);              /* 8  */
     16     r = r + (12 | 10);              /* 14 */
     17     r = r + (12 ^ 10);              /* 6  */
     18     r = r + !0;                     /* 1  */
     19     r = r + ~0;                     /* -1 */
     20     r = r + (-1);                   /* -1 */
     21     return r;                       /* 88 */
     22 }
     23 
     24 int main(int argc, char **argv) {
     25     if (test_arith() != 88) return 1;
     26     return 0;
     27 }