Add tests for #34598
authorMiguel de Icaza <miguel@gnome.org>
Tue, 13 Oct 2015 18:48:55 +0000 (14:48 -0400)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 13 Oct 2015 18:48:55 +0000 (14:48 -0400)
mono/tests/thread-static-init.cs

index 3186833121dd7540f2d94bf1c27b6327398b9e67..34131596fef0070cf0489478a90f926e90362e0b 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.InteropServices;
 
 class Foo {
        [ThreadStatic]
@@ -7,15 +8,54 @@ class Foo {
 
 class X {
 
-        static void Main ()
+        static int Main ()
         {
                Foo.foo = 1;
                new Foo ();
                Bar ();
+
+               return Bug34598 ();
         }
+
+       static int Bug34598 ()
+       {
+               if (Test.Zero.ToString () != "0")
+                       return 1;
+               if (Test.One.ToString () != "1")
+                       return 2;
+               if (Test.Two.ToString () != "2")
+                       return 3;
+
+               if (Test2.Zero.ToString () != "0")
+                       return 4;
+               if (Test2.One.ToString () != "1")
+                       return 5;
+               if (Test2.Two.ToString () != "2")
+                       return 6;
+               return 0;
+       }
        
        static void Bar ()
        {
                Console.WriteLine (Foo.foo);
        }
 }
+
+[StructLayout(LayoutKind.Explicit)]
+public struct Test
+{
+       public static float Zero = 0.0f;
+       [ThreadStatic]
+       public static float One = 1.0f;
+       [ContextStatic]
+       public static float Two = 2.0f;
+}
+
+public struct Test2
+{
+       public static float Zero = 0.0f;
+       [ThreadStatic]
+       public static float One = 1.0f;
+       [ContextStatic]
+       public static float Two = 2.0f;
+}