New test.
authorPaolo Molaro <lupus@oddwiz.org>
Mon, 5 Aug 2002 11:08:07 +0000 (11:08 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Mon, 5 Aug 2002 11:08:07 +0000 (11:08 -0000)
svn path=/trunk/mono/; revision=6410

mono/tests/Makefile.am
mono/tests/cattr-object.cs [new file with mode: 0644]

index ea2499bbe820e05b0643b0c37f62a56fe74af81f..5c2dc98379ea4eafb71a2cbea36eb758c0be5e4a 100644 (file)
@@ -59,6 +59,8 @@ TEST_CS_SRC=                  \
        assignable-tests.cs     \
        array-cast.cs           \
        cattr-compile.cs        \
+       cattr-field.cs          \
+       cattr-object.cs         \
        custom-attr.cs          \
        double-cast.cs          \
        newobj-valuetype.cs     \
diff --git a/mono/tests/cattr-object.cs b/mono/tests/cattr-object.cs
new file mode 100644 (file)
index 0000000..961a0f1
--- /dev/null
@@ -0,0 +1,41 @@
+using System;
+
+[My(1)]
+[My(TypeCode.Empty)]
+[My(typeof(System.Enum))]
+class T {
+       static int Main() {
+               object[] a = Attribute.GetCustomAttributes (typeof (T), true);
+               if (a.Length != 3)
+                       return 1;
+               foreach (object o in a) {
+                       My attr = (My)o;
+                       if (attr.obj.GetType () == typeof(int)) {
+                               int val = (int)attr.obj;
+                               Console.WriteLine ("got value: {0}", val);
+                               if (val != 1)
+                                       return 2;
+                       } else if (attr.obj.GetType () == typeof(System.TypeCode)) {
+                               TypeCode val = (TypeCode)attr.obj;
+                               if (val != TypeCode.Empty)
+                                       return 3;
+                       } else {
+                               Type t = attr.obj as Type;
+                               if (t == null)
+                                       return 4;
+                               if (t != typeof (System.Enum))
+                                       return 5;
+                       }
+                       
+               }
+               return 0;
+       }
+}
+
+[AttributeUsage(AttributeTargets.All,AllowMultiple=true)]
+class My : Attribute {
+       public object obj;
+       public My (object o) {
+               obj = o;
+       }
+}