2004-09-22 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / tests / test-297.cs
1 using System;
2
3 [My((long)1)]
4 [My(TypeCode.Empty)]
5 [My(typeof(System.Enum))]
6 class T {
7         static int Main() {
8                 object[] a = Attribute.GetCustomAttributes (typeof (T), false);
9                 if (a.Length != 3)
10                         return 1;
11                 foreach (object o in a) {
12                         My attr = (My)o;
13                         if (attr.obj.GetType () == typeof (long)) {
14                                 long val = (long) attr.obj;
15                                 if (val != 1)
16                                         return 2;
17                         } else if (attr.obj.GetType () == typeof (TypeCode)) {
18                                 TypeCode val = (TypeCode) attr.obj;
19                                 if (val != TypeCode.Empty)
20                                         return 3;
21                         } else if (attr.obj.GetType ().IsSubclassOf (typeof (Type))) {
22                                 Type val = (Type) attr.obj;
23                                 if (val != typeof (System.Enum))
24                                         return 4;
25                         } else
26                                 return 5;
27                         
28                 }
29                 return 0;
30         }
31 }
32
33 [AttributeUsage(AttributeTargets.All,AllowMultiple=true)]
34 class My : Attribute {
35         public object obj;
36         public My (object o) {
37                 obj = o;
38         }
39 }