Merge pull request #1304 from slluis/mac-proxy-autoconfig
[mono.git] / mcs / tests / test-898.cs
1 // Compiler options: -unsafe
2  
3 using System;
4
5 class BoolArrayWithByteValues
6 {
7
8         static int Foo (ref bool b)
9         {
10                 bool b2 = true;
11                 bool r;
12                 r = b == true;
13                 if (!r)
14                         return 10;
15
16                 r = b == b2;
17                 if (!r)
18                         return 11;
19
20                 return 0;
21         }
22
23         static unsafe bool Ptr ()
24         {
25                 bool rv;
26         
27                 var arr = new byte [256];
28                 for (int i = 0; i < arr.Length; i++)
29                         arr [i] = (byte) i;
30                 fixed (byte* bptr = arr) {
31                         rv = true;
32                         for (int i = 0; i < arr.Length; i++) {
33                                 bool* boptr = (bool*)(bptr + i);
34                                 if (arr[i] > 0 && !*boptr)
35                                         rv = false;
36                                 System.Console.WriteLine ("#{0} = {1}", i, *boptr);
37                         }
38                 }
39
40                 return rv;
41         }
42
43         static int Main()
44         {
45                 var a = new bool[1];
46                 Buffer.SetByte (a, 0, 5);
47
48                 var b = true;
49                 bool r;
50                 r = a [0];
51                 if (!r)
52                         return 1;
53
54                 r = a [0] == true;
55                 if (!r)
56                         return 2;
57
58                 r = a [0] == b;
59                 if (!r)
60                         return 3;
61
62                 r = a [0] != false;
63                 if (!r)
64                         return 4;
65
66                 r = a [0] != b;
67                 if (r)
68                         return 5;
69
70                 var res = Foo (ref a [0]);
71                 if (res != 0)
72                         return res;
73
74                 if (!Ptr ())
75                         return 6;
76
77                 return 0;
78         }
79 }