Merge pull request #5439 from alexrp/master
[mono.git] / mcs / tests / test-244.cs
1 using System;
2
3 class Foo {
4         static int t_count = 0, f_count = 0;
5
6         public static int Main ()
7         {
8                 Console.WriteLine (t && f);
9                 if (t_count != 1)
10                         return 1;
11                 if (f_count != 1)
12                         return 2;
13                 Console.WriteLine ();
14                 Console.WriteLine (t && t);
15                 if (t_count != 3)
16                         return 3;
17                 if (f_count != 1)
18                         return 4;
19                 Console.WriteLine ();
20                 return 0;
21         }
22         
23         static MyBool t { get { Console.WriteLine ("t"); t_count++; return new MyBool (true); }}
24         static MyBool f { get { Console.WriteLine ("f"); f_count++; return new MyBool (false); }}
25 }
26
27 public struct MyBool {
28         bool v;
29         
30         public MyBool (bool v) { this.v = v; }
31         
32         public static MyBool operator & (MyBool x, MyBool y) {
33                 return new MyBool (x.v & y.v);  
34         }
35         
36         public static MyBool operator | (MyBool x, MyBool y) {
37                 return new MyBool (x.v | y.v);  
38         }
39         
40         public static bool operator true (MyBool x) {
41                 return x.v;  
42         }
43         
44         public static bool operator false (MyBool x) {
45                 return ! x.v;  
46         }
47         
48         public override string ToString () { return v.ToString (); }
49 }