Fix a ConditionalWeakTable test.
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 19 Jun 2012 21:04:57 +0000 (18:04 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 19 Jun 2012 21:05:19 +0000 (18:05 -0300)
mcs/class/corlib/Test/System.Runtime.CompilerServices/ConditionalWeakTableTest.cs

index 2e80f7f3841f062503a181c1a924527dc6fd1ec3..f4869bc6d3591a5522ad85ee4f3fe842b859d679 100644 (file)
@@ -52,8 +52,20 @@ namespace MonoTests.System.Runtime.CompilerServices {
                }
        }
 
-       class Key { public int Foo; }
-       class Val { public int Foo; }
+       class Key {
+               public int Foo;
+               public override string ToString () {
+                               return "key-" + Foo;
+                       }
+       }
+
+       class Val {
+               public int Foo;
+               public override string ToString () {
+                       return "value-" + Foo;
+               }
+       }
+       
 
        [Test]
        public void GetValue () {
@@ -448,7 +460,7 @@ namespace MonoTests.System.Runtime.CompilerServices {
        public void OldGenKeysMakeNewGenObjectsReachable ()
        {
                if (GC.MaxGeneration == 0) /*Boehm doesn't handle ephemerons */
-               return;
+                       return;
                ConditionalWeakTable<object, Val> table = new ConditionalWeakTable<object, Val>();
                List<Key> keys = new List<Key>();
 
@@ -457,21 +469,21 @@ namespace MonoTests.System.Runtime.CompilerServices {
                // should be collected ever.
                //
                for (int x = 0; x < 1000; x++) 
-               keys.Add(new Key() { Foo = x });
+                       keys.Add (new Key () { Foo = x });
 
-               for (int i = 0; i < 10000; ++i) {
+               for (int i = 0; i < 1000; ++i) {
                        // Insert all keys into the ConditionalWeakTable
                        foreach (var key in keys)
-                       table.Add(key, new Val() { Foo = key.Foo });
+                               table.Add (key, new Val () { Foo = key.Foo });
 
                        // Look up all keys to verify that they are still there
                        Val val;
                        foreach (var key in keys)
-                               Assert.IsTrue (table.TryGetValue(key, out val), "#1-" + i);
+                               Assert.IsTrue (table.TryGetValue (key, out val), "#1-" + i + "-k-" + key);
 
                        // Remove all keys from the ConditionalWeakTable
                        foreach (var key in keys)
-                               Assert.IsTrue (!table.Remove(key), "#2-" + i);
+                               Assert.IsTrue (table.Remove (key), "#2-" + i + "-k-" + key);
                }
        }
        }