[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tests / test-91.cs
blob344efd5145c78b2968cad855c61ce4057a8eae11
1 using System;
2 using System.Reflection;
4 //
5 // Test the setting for the default public constructor
6 //
7 abstract class Abstract {
11 // Test the setting for the default public consturctor
13 class Plain {
16 class Test {
18 static protected internal void MyProtectedInternal () { }
19 static internal void MyInternal() { }
20 static public void MyPublic () { }
21 static void MyPrivate () {}
23 public static int Main ()
25 Type myself = typeof (Test);
26 BindingFlags bf = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
27 MethodAttributes mpia;
28 MethodInfo mpi;
31 // protected internal
33 mpi = myself.GetMethod ("MyProtectedInternal", bf);
34 mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
35 if (mpia != MethodAttributes.FamORAssem)
36 return 1;
39 // internal
41 mpi = myself.GetMethod ("MyInternal", bf);
42 mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
43 if (mpia != MethodAttributes.Assembly)
44 return 2;
47 // public
49 mpi = myself.GetMethod ("MyPublic", bf);
50 mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
51 if (mpia != MethodAttributes.Public)
52 return 3;
55 // private
57 mpi = myself.GetMethod ("MyPrivate", bf);
58 mpia = mpi.Attributes & MethodAttributes.MemberAccessMask;
59 if (mpia != MethodAttributes.Private)
60 return 4;
63 // Test 17.10.4 accessibility (default constructor permissions)
65 ConstructorInfo ci = typeof (Abstract).GetConstructor
66 (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type [0], new
67 ParameterModifier [0]);
69 if (!ci.IsFamily)
70 return 5;
72 ci = typeof (Plain).GetConstructor
73 (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type [0], new
74 ParameterModifier [0]);
76 if (!ci.IsPublic)
77 return 6;
79 Console.WriteLine ("All tests pass");
80 return 0;