Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / thread-static-init.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 class Foo {
5         [ThreadStatic]
6         public static int foo;
7 }
8
9 class X {
10
11         static int Main ()
12         {
13                 Foo.foo = 1;
14                 new Foo ();
15                 Bar ();
16
17                 return Bug34598 ();
18         }
19
20         static int Bug34598 ()
21         {
22                 if (Test.Zero.ToString () != "0")
23                         return 1;
24                 if (Test.One.ToString () != "1")
25                         return 2;
26                 if (Test.Two.ToString () != "2")
27                         return 3;
28
29                 if (Test2.Zero.ToString () != "0")
30                         return 4;
31                 if (Test2.One.ToString () != "1")
32                         return 5;
33                 if (Test2.Two.ToString () != "2")
34                         return 6;
35                 return 0;
36         }
37         
38         static void Bar ()
39         {
40                 Console.WriteLine (Foo.foo);
41         }
42 }
43
44 [StructLayout(LayoutKind.Explicit)]
45 public struct Test
46 {
47         public static float Zero = 0.0f;
48         [ThreadStatic]
49         public static float One = 1.0f;
50         [ContextStatic]
51         public static float Two = 2.0f;
52 }
53
54 public struct Test2
55 {
56         public static float Zero = 0.0f;
57         [ThreadStatic]
58         public static float One = 1.0f;
59         [ContextStatic]
60         public static float Two = 2.0f;
61 }