New test.
[mono.git] / mcs / class / corlib / Test / System.Reflection / FieldInfoTest.cs
index 311ca402c534c75b2ef74e4704613351e38e675d..4ad97602f8f7b3d9a75fbdf52ba637501d70e3c7 100644 (file)
@@ -118,12 +118,20 @@ public class FieldInfoTest : Assertion
                f.SetValue (null, 8);
        }
 
+       const int literal = 42;
+
+       [Test]
+       [ExpectedException (typeof (FieldAccessException))]
+       public void SetValueOnLiteralField ()
+       {
+               FieldInfo f = typeof (FieldInfoTest).GetField ("literal", BindingFlags.Static | BindingFlags.NonPublic);
+               f.SetValue (null, 0);
+       }
+
        public int? nullable_field;
 
        public static int? static_nullable_field;
 
-       public string? nullable_reference_field;
-
        [Test]
        public void NullableTests ()
        {
@@ -142,13 +150,6 @@ public class FieldInfoTest : Assertion
                AssertEquals (101, fi2.GetValue (t));
                fi2.SetValue (t, null);
                AssertEquals (null, fi2.GetValue (t));
-
-               FieldInfo fi3 = typeof (FieldInfoTest).GetField ("nullable_reference_field");
-
-               fi3.SetValue (t, "ABC");
-               AssertEquals ("ABC", fi3.GetValue (t));
-               fi3.SetValue (t, null);
-               AssertEquals (null, fi3.GetValue (t));
        }
 #endif
 }