dlr bug
[mcs.git] / tests / gtest-142.cs
blob1347905dcfa472edebd7c1c1dbc40f5f5ae12dfa
1 using System;
3 public static class Assert
5 public static int Errors {
6 get { return errors; }
9 static int errors = 0;
11 static void Error (string method, string text)
13 Console.WriteLine ("Assert failed: {0} ({1})", method, text);
14 errors++;
17 public static void IsTrue (string text, bool b)
19 if (!b)
20 Error ("IsTrue", text);
23 public static void IsFalse (string text, bool b)
25 if (b)
26 Error ("IsFalse", text);
29 public static void IsNull<T> (string text, Nullable<T> nullable)
30 where T : struct
32 if (nullable.HasValue)
33 Error ("IsNull", text);
36 public static void IsNotNull<T> (string text, Nullable<T> nullable)
37 where T : struct
39 if (!nullable.HasValue)
40 Error ("IsNotNull", text);
43 public static void IsTrue (string text, Nullable<bool> b)
45 if (!b.HasValue || !b.Value)
46 Error ("IsTrue", text);
49 public static void IsFalse (string text, Nullable<bool> b)
51 if (!b.HasValue || b.Value)
52 Error ("IsFalse", text);
56 class X
58 static int Main ()
60 bool? a = null, b = false, c = true;
61 bool? d = null, e = false, f = true;
63 Assert.IsNull ("a", a);
64 Assert.IsFalse ("b", b);
65 Assert.IsTrue ("c", c);
66 Assert.IsTrue ("a == d", a == d);
67 Assert.IsTrue ("b == e", b == e);
68 Assert.IsTrue ("c == f", c == f);
70 Assert.IsFalse ("a != d", a != d);
71 Assert.IsFalse ("a == b", a == b);
72 Assert.IsTrue ("a != b", a != b);
74 Assert.IsNull ("d & a", d & a);
75 Assert.IsFalse ("d & b", d & b);
76 Assert.IsNull ("d & c", d & c);
77 Assert.IsFalse ("e & a", e & a);
78 Assert.IsFalse ("e & b", e & b);
79 Assert.IsFalse ("e & c", e & c);
80 Assert.IsNull ("f & a", f & a);
81 Assert.IsFalse ("f & b", f & b);
82 Assert.IsTrue ("f & c", f & c);
84 Assert.IsNull ("d | a", d | a);
85 Assert.IsNull ("d | b", d | b);
86 Assert.IsTrue ("d | c", d | c);
87 Assert.IsNull ("e | a", e | a);
88 Assert.IsFalse ("e | b", e | b);
89 Assert.IsTrue ("e | c", e | c);
90 Assert.IsTrue ("f | a", f | a);
91 Assert.IsTrue ("f | b", f | b);
92 Assert.IsTrue ("f | c", f | c);
94 int? g = 3, h = null, i = 3, j = null;
96 Assert.IsFalse ("g == null", g == null);
97 Assert.IsTrue ("g != null", g != null);
98 Assert.IsTrue ("h == null", h == null);
99 Assert.IsFalse ("h != null", h != null);
101 Assert.IsTrue ("g == i", g == i);
102 Assert.IsFalse ("g != i", g != i);
103 Assert.IsFalse ("g == j", g == j);
104 Assert.IsTrue ("g != j", g != j);
105 Assert.IsFalse ("h == i", h == i);
106 Assert.IsTrue ("h != i", h != i);
107 Assert.IsTrue ("h == j", h == j);
108 Assert.IsFalse ("h != j", h != j);
110 Console.WriteLine ("{0} errors.", Assert.Errors);
111 return Assert.Errors;