blob: 4f2d2e78f4be1d800889a0e72d2d8d9c51f79aba [file] [log] [blame]
Jack Palevichbf42c9c2009-05-12 12:48:35 -07001/* Test operators */
2
3testInc() { int a, b; a = 3; b = a++; printf("3++ = %d %d\n", b, a); }
4testDec() { int a, b; a = 3; b = a--; printf("3-- = %d %d\n", b, a); }
5testTimes(){ printf("%d * %d = %d\n", 10, 4, 10 * 4); }
6testDiv(){ printf("%d / %d = %d\n", 11, 4, 11 / 4); }
7testMod(){ printf("%d %% %d = %d\n", 11, 4, 11 % 4); }
8testPlus(){ printf("%d + %d = %d\n", 10, 4, 10 + 4); }
9testMinus(){ printf("%d - %d = %d\n", 10, 4, 10 - 4); }
10testShiftLeft(){ printf("%d << %d = %d\n", 10, 4, 10 << 4); }
11testShiftRight(){ printf("%d >> %d = %d\n", 100, 4, 100 >> 4); }
12testLess(){ printf("%d < %d = %d\n", 10, 4, 10 < 4); }
13testLesEqual(){ printf("%d <= %d = %d\n", 10, 4, 10 <= 4); }
14testGreater(){ printf("%d > %d = %d\n", 10, 4, 10 > 4); }
15testGreaterEqual(){ printf("%d >= %d = %d\n", 10, 4, 10 >= 4); }
16testEqualTo(){ printf("%d == %d = %d\n", 10, 4, 10 == 4); }
17testNotEqualTo(){ printf("%d != %d = %d\n", 10, 4, 10 != 4); }
18testBitAnd(){ printf("%d & %d = %d\n", 10, 7, 10 & 7); }
19testBitXor(){ printf("%d ^ %d = %d\n", 10, 7, 10 ^ 7); }
20testBitOr(){ printf("%d | %d = %d\n", 10, 4, 10 | 4); }
21testAssignment(){ int a, b; a = 3; b = a; printf("b == %d\n", b); }
22testLogicalAnd(){ printf("%d && %d = %d\n", 10, 4, 10 && 4); }
23testLogicalOr(){ printf("%d || %d = %d\n", 10, 4, 10 || 4); }
24testAddressOf(){ int a; printf("&a is %d\n", &a); }
25testPointerIndirection(){ int a, b; a = &b; b = 17; printf("*%d = %d =?= %d\n", a, * (int*) a, b); }
26testNegation(){ printf("-%d = %d\n", 10, -10); }
27testUnaryPlus(){ printf("+%d = %d\n", 10, +10); }
28testUnaryNot(){ printf("!%d = %d\n", 10, !10); }
29testBitNot(){ printf("~%d = %d\n", 10, ~10); }
30
31main(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}