Author: zoltan
Date: 2007-12-03 09:10:08 -0500 (Mon, 03 Dec 2007)
New Revision: 90544

Modified:
   trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
   trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs
Log:
2007-12-03  Zoltan Varga  <[EMAIL PROTECTED]>

        * FieldInfoTest.cs: Add GetRawDefaultValue () tests.


Modified: trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2007-12-03 
14:00:37 UTC (rev 90543)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2007-12-03 
14:10:08 UTC (rev 90544)
@@ -1,3 +1,7 @@
+2007-12-03  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * FieldInfoTest.cs: Add GetRawDefaultValue () tests.
+
 2007-11-05  Mark Probst  <[EMAIL PROTECTED]>
 
        * BinderTests.cs: Add test for bug #324998.

Modified: trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs      
2007-12-03 14:00:37 UTC (rev 90543)
+++ trunk/mcs/class/corlib/Test/System.Reflection/FieldInfoTest.cs      
2007-12-03 14:10:08 UTC (rev 90544)
@@ -316,6 +316,46 @@
                        Assert.IsNotNull (f);
                }
 #endif // TARGET_JVM
+
+               [Test]
+               public void GetRawDefaultValue ()
+               {
+                       Assert.AreEqual (5, typeof (FieldInfoTest).GetField 
("int_field").GetRawConstantValue ());
+                       Assert.AreEqual (Int64.MaxValue, typeof 
(FieldInfoTest).GetField ("long_field").GetRawConstantValue ());
+                       Assert.AreEqual (2, typeof (FieldInfoTest).GetField 
("int_enum_field").GetRawConstantValue ());
+                       Assert.AreEqual (typeof (int), typeof 
(FieldInfoTest).GetField ("int_enum_field").GetRawConstantValue ().GetType ());
+                       Assert.AreEqual (2, typeof (FieldInfoTest).GetField 
("long_enum_field").GetRawConstantValue ());
+                       Assert.AreEqual (typeof (long), typeof 
(FieldInfoTest).GetField ("long_enum_field").GetRawConstantValue ().GetType ());
+                       Assert.AreEqual ("Hello", typeof 
(FieldInfoTest).GetField ("string_field").GetRawConstantValue ());
+                       Assert.AreEqual (null, typeof (FieldInfoTest).GetField 
("object_field").GetRawConstantValue ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetRawDefaultValueNoDefault ()
+               {
+                       typeof (FieldInfoTest).GetField 
("non_const_field").GetRawConstantValue ();
+               }
+
+               public enum IntEnum {
+                       First = 1,
+                       Second = 2,
+                       Third = 3
+               }
+
+               public enum LongEnum : long {
+                       First = 1,
+                   Second = 2,
+                       Third = 3
+               }
+
+               public const int int_field = 5;
+               public const long long_field = Int64.MaxValue;
+               public const IntEnum int_enum_field = IntEnum.Second;
+               public const LongEnum long_enum_field = LongEnum.Second;
+               public const string string_field = "Hello";
+               public const FieldInfoTest object_field = null;
+               public int non_const_field;
        
 #endif
        }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to