[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mono / tests / interlocked-2.2.cs
index 35a4140fe45bbc41a9c722fac6993dd1b9293964..c16f700f75facc8e1f56e0643e1e9003924e3e58 100644 (file)
@@ -4,7 +4,7 @@ using System.Threading;
 public class InterlockTest
 {
        public int test;
-       public int ltest;
+       public long ltest;
 
        public static int Main() {
                int a,b;
@@ -30,7 +30,7 @@ public class InterlockTest
 
                /* long */
                it.ltest = 2;
-               int lc = Interlocked.Add (ref it.ltest, 1);
+               long lc = Interlocked.Add (ref it.ltest, 1);
                if (lc != 3)
                        return 5;
 
@@ -44,6 +44,17 @@ public class InterlockTest
                if (lb != 2)
                        return 8;
 
+               if (Interlocked.Read (ref la) != 2)
+                       return 9;
+
+               la = 1;
+               lc = Interlocked.Exchange (ref la, 2);
+               if (lc != 1)
+                       return 10;
+
+               if (la != 2)
+                       return 11;
+
                /* Generics */
                InterlockTest o1 = new InterlockTest ();
                InterlockTest o2 = new InterlockTest ();
@@ -51,15 +62,35 @@ public class InterlockTest
 
                InterlockTest o3 = Interlocked.CompareExchange (ref o, o2, o2);
                if (o3 != o1)
-                       return 9;
+                       return 12;
                if (o != o1)
-                       return 10;
+                       return 13;
 
                InterlockTest o4 = Interlocked.CompareExchange (ref o, o2, o1);
                if (o4 != o1)
-                       return 11;
+                       return 14;
                if (o != o2)
-                       return 12;
+                       return 15;
+
+               /* long increment/decrement */
+               la = 0x12345678;
+               lb = Interlocked.Increment (ref la);
+               if (la != 0x12345679)
+                       return 16;
+               if (lb != 0x12345679)
+                       return 16;
+               lb = Interlocked.Decrement (ref la);
+               if (la != 0x12345678)
+                       return 17;
+               if (lb != 0x12345678)
+                       return 18;              
+
+               la = 1;
+               lb = Interlocked.CompareExchange (ref la, 2, 1);
+               if (la != 2)
+                       return 19;
+               if (lb != 1)
+                       return 20;
 
                Console.WriteLine ("done!");