summaryrefslogtreecommitdiff
path: root/tests/src/JIT/CodeGenBringUpTests/StaticValueField.cs
blob: a1d8448c3602ca51b8435fe70100dd26ec4a14ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//

using System;
struct TestValue
{
  public int a;
  public short b;
  public long c;
}

// This test stores a primitive (no-GC fields) value type to a static field
// and checks if the contents are correct.
class StaticValueField
{
  const int Pass = 100;
  const int Fail = -1;
  static TestValue sField;
  public static void Init()
  {
    TestValue v = new TestValue();
    v.a = 100;
    v.b = 200;
    v.c = 300;
    sField = v;
  }

  public static int Main()
  {
    Init();
    if (sField.a == 100
      && sField.b == 200
      && sField.c == 300)
    {
      return Pass;
    }
    return Fail;
  }
}