2010-05-31 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-35.cs
blobd9bc1d8338e92bf0e57d25bd53587e9ea35e0cef
1 //
2 // This test checks the !x optimization for if/while/for/do
3 //
4 class X {
6 static bool t = true;
7 static bool f = false;
8 static int j = 0;
10 static void a ()
12 if (!t)
13 j = 1;
16 static void w (int x)
18 System.Console.WriteLine (" " + x);
21 static int Main ()
23 int ok = 0, error = 0;
25 if (!f)
26 ok = 1;
27 else
28 error++;
30 w (1);
31 if (f)
32 error++;
33 else
34 ok |= 2;
36 w(2);
37 if (t)
38 ok |= 4;
39 else
40 error++;
42 if (!t)
43 error++;
44 else
45 ok |= 8;
47 if (!(t && f == false))
48 error++;
49 else
50 ok |= 16;
52 int i = 0;
53 w(3);
54 do {
55 i++;
56 } while (!(i > 5));
57 if (i != 6)
58 error ++;
59 else
60 ok |= 32;
62 w(100);
63 System.Console.WriteLine ("Value: " + t);
64 do {
65 i++;
66 } while (!t);
68 System.Console.WriteLine ("Ok=" + ok + " Errors=" + error);
69 return ((ok == 63) && (error == 0)) ? 0 : 1;