summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Methodical/Invoke/ctor/val_ctor.cs
blob: 9cbadcc2029474f720dd62fa9108176e2863daec (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
42
43
44
45
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace JitTest
{
    internal struct TestStruct
    {
        private long _m_testParam;
        private static long s_m_sum = 0;

        private TestStruct(ulong testParam)
        {
            _m_testParam = (long)testParam;
            s_m_sum += _m_testParam;
            if (s_m_sum < 100)
            {
                //In IL, this will be changed to newobj
                TestStruct ts = new TestStruct(testParam + 1);
            }
        }

        private static int Main()
        {
            try
            {
                //In IL, this will be changed to newobj
                TestStruct test = new TestStruct(0);
                if (s_m_sum != 105)
                {
                    Console.WriteLine("Failed");
                    return 1;
                }
            }
            catch
            {
                Console.WriteLine("Failed w/ exception");
                return 2;
            }
            Console.WriteLine("Passed");
            return 100;
        }
    }
}