summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Methodical/xxobj/operand/unbox.cs
blob: 24d07b35d6e475b0bbbbadbe24b5b4638d6de567 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// 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 Test
    {
        private int _m_v;

        private static int unbox_ldobj()
        {
            Test T = new Test();
            T._m_v = 1;
            object R = T;
            return ((Test)R)._m_v - 1;
        }

        private static int unbox_initobj()
        {
            Test T = new Test();
            T._m_v = 1;
            object R = T;
            R = new Test();     //change to unbox<R> = new Test() in IL
            return ((Test)R)._m_v;
        }

        private static int unbox_cpobj()
        {
            Test T = new Test();
            T._m_v = 1;
            Test T1 = new Test();
            object R = T;
            R = T1;     //change to unbox<R> = T1 in IL
            return ((Test)R)._m_v;
        }

        private static int unbox_stobj()
        {
            Test T = new Test();
            T._m_v = 1;
            Test T1 = new Test();
            object R = T;
            R = T1;     //change to unbox<R> = T1 in IL 
            return ((Test)R)._m_v;
        }

        private static int Main()
        {
            if (unbox_ldobj() != 0)
            {
                return 101;
            }
            if (unbox_initobj() != 0)
            {
                return 102;
            }
            if (unbox_stobj() != 0)
            {
                return 103;
            }
            if (unbox_cpobj() != 0)
            {
                return 104;
            }
            return 100;
        }
    }
}