GenericParameter.cs: override Module properly
[mcs.git] / tests / dtest-error-01.cs
blob52b3de623a072140dfc779a5709fa2bba5ff525e
1 // Compiler options: -unsafe
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Reflection;
7 using Microsoft.CSharp.RuntimeBinder;
9 class Helper
11 public unsafe static int* Foo (int i)
13 return null;
17 class Tester
19 #pragma warning disable 169
20 void Unsafe_1 ()
22 dynamic d = 1;
23 AssertError (
24 () => Helper.Foo (d),
25 "Pointers and fixed size buffers cannot be used in a dynamic context");
28 #pragma warning restore 169
30 static void AssertError (Action a, string msg)
32 try {
33 a ();
34 } catch (RuntimeBinderException e) {
35 if (e.Message != msg)
36 throw;
38 return;
41 throw new ApplicationException ("Expected error");
44 static bool RunTest (MethodInfo test)
46 Console.Write ("Running test {0, -25}", test.Name);
47 try {
48 test.Invoke (new Tester (), null);
49 Console.WriteLine ("OK");
50 return true;
51 } catch (Exception e) {
52 Console.WriteLine ("FAILED");
53 Console.WriteLine (e.InnerException.Message);
54 return false;
58 public static int Main ()
60 var tests = from test in typeof (Tester).GetMethods (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)
61 where test.GetParameters ().Length == 0
62 orderby test.Name
63 select RunTest (test);
65 int failures = tests.Count (a => !a);
66 Console.WriteLine (failures + " tests failed");
67 return failures;