Home | History | Annotate | Download | only in src
      1 /* Test operators */
      2 
      3 testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); }
      4 testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); }
      5 testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); }
      6 testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); }
      7 testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); }
      8 testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); }
      9 testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); }
     10 testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); }
     11 testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); }
     12 testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); }
     13 testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); }
     14 testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); }
     15 testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); }
     16 testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); }
     17 testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); }
     18 testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); }
     19 testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); }
     20 testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); }
     21 testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); }
     22 testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); }
     23 testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); }
     24 testAddressOf(){ int a; printf("&a is %d\n", &a); }
     25 testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d  = %d =?= %d\n", a, * (int*) a, b); }
     26 testNegation(){ printf("-%d = %d\n", 10, -10); }
     27 testUnaryPlus(){ printf("+%d = %d\n", 10, +10); }
     28 testUnaryNot(){ printf("!%d = %d\n", 10, !10); }
     29 testBitNot(){ printf("~%d = %d\n", 10, ~10); }
     30 
     31 main(a,b) {
     32     testInc();
     33     testDec();
     34     testTimes();
     35     testDiv();
     36     testMod();
     37     testPlus();
     38     testMinus();
     39     testShiftLeft();
     40     testShiftRight();
     41     testLess();
     42     testLesEqual();
     43     testGreater();
     44     testGreaterEqual();
     45     testEqualTo();
     46     testNotEqualTo();
     47     testBitAnd();
     48     testBinXor();
     49     testBitOr();
     50     testAssignment();
     51     testLogicalAnd();
     52     testLogicalOr();
     53     testAddressOf();
     54     testPointerIndirection();
     55     testNegation();
     56     testUnaryPlus();
     57     testUnaryNot();
     58     testBitNot();
     59     return 0;
     60 }