cosmetic
[mcs.git] / tests / test-47.cs
blobc269d0b6c712a2082c200004db2d2d1679ee211c
1 //
2 // Short-circuit evaluation tests
3 //
4 using System;
6 class X {
8 static int t_count = 0;
9 static int f_count = 0;
11 static bool f ()
13 Console.WriteLine ("f");
14 f_count++;
15 return false;
18 static bool t ()
20 Console.WriteLine ("t");
21 t_count++;
22 return true;
25 static int Main ()
27 if (t () && t ()){
28 f_count--;
31 if (t_count != 2)
32 return 1;
34 if (f_count != -1)
35 return 3;
37 f_count = 0;
39 if (t () && f ())
40 if (t_count != 3 && f_count == 1)
41 return 2;
43 if (f () && f ())
44 return 3;
46 if (f_count != 2)
47 return 4;
49 if (f () && t ())
50 return 5;
52 if (f_count != 3)
53 return 6;
55 if (t_count != 3)
56 return 7;
59 // reset
61 Console.WriteLine ("or");
63 t_count = f_count = 0;
65 if (t () || t ()){
66 if (t_count != 1)
67 return 8;
68 } else
69 return 9;
71 if (t () || f ()){
72 if (f_count != 0)
73 return 10;
74 if (t_count != 2)
75 return 16;
76 } else
77 return 11;
79 if (f () || f ()){
80 return 12;
81 } else
82 if (f_count != 2)
83 return 13;
85 if (f () || t ()){
86 if (f_count != 3)
87 return 15;
88 if (t_count != 3)
89 return 17;
90 } else
91 return 14;
93 return 0;