1 // Compiler options: -unsafe
4 using System
.Collections
.Generic
;
6 using System
.Reflection
;
7 using Microsoft
.CSharp
.RuntimeBinder
;
11 public unsafe static int* Foo (int i
)
19 #pragma warning disable 169
26 }, "Cannot invoke a non-delegate type `int'");
33 using (dynamic d
= 1) { }
34 }, "Cannot implicitly convert type `int' to `System.IDisposable'");
42 "Pointers and fixed size buffers cannot be used in a dynamic context");
45 void NullableConversion ()
53 }, "Operator `&=' cannot be applied to operands of type `bool' and `byte?'");
56 #pragma warning restore 169
58 static void AssertError (Action a
, string msg
)
62 } catch (RuntimeBinderException e
) {
64 throw new ApplicationException ("Expected error message: " + e
.Message
);
69 throw new ApplicationException ("Expected error");
72 static bool RunTest (MethodInfo test
)
74 Console
.Write ("Running test {0, -25}", test
.Name
);
76 test
.Invoke (new Tester (), null);
77 Console
.WriteLine ("OK");
79 } catch (Exception e
) {
80 Console
.WriteLine ("FAILED");
81 Console
.WriteLine (e
.InnerException
.Message
);
86 public static int Main ()
88 var tests
= from test
in typeof (Tester
).GetMethods (BindingFlags
.Instance
| BindingFlags
.NonPublic
| BindingFlags
.DeclaredOnly
)
89 where test
.GetParameters ().Length
== 0
91 select RunTest (test
);
93 int failures
= tests
.Count (a
=> !a
);
94 Console
.WriteLine (failures
+ " tests failed");