• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Test operators */
2 
testInc()3 testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); }
testDec()4 testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); }
testTimes()5 testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); }
testDiv()6 testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); }
testMod()7 testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); }
testPlus()8 testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); }
testMinus()9 testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); }
testShiftLeft()10 testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); }
testShiftRight()11 testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); }
testLess()12 testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); }
testLesEqual()13 testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); }
testGreater()14 testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); }
testGreaterEqual()15 testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); }
testEqualTo()16 testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); }
testNotEqualTo()17 testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); }
testBitAnd()18 testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); }
testBitXor()19 testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); }
testBitOr()20 testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); }
testAssignment()21 testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); }
testLogicalAnd()22 testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); }
testLogicalOr()23 testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); }
testAddressOf()24 testAddressOf(){ int a; printf("&a is %d\n", &a); }
testPointerIndirection()25 testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d  = %d =?= %d\n", a, * (int*) a, b); }
testNegation()26 testNegation(){ printf("-%d = %d\n", 10, -10); }
testUnaryPlus()27 testUnaryPlus(){ printf("+%d = %d\n", 10, +10); }
testUnaryNot()28 testUnaryNot(){ printf("!%d = %d\n", 10, !10); }
testBitNot()29 testBitNot(){ printf("~%d = %d\n", 10, ~10); }
30 
main(a,b)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 }