summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Methodical/VT/callconv/jumps.cs
blob: 6b312357935b056355d204e4dc89eb3adf2178fa (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// 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 MS
{
    internal struct VT
    {
        private String _path;
        private int _target;

        public override String ToString()
        {
            _path += "->ToString";
            switch (_target)
            {
                case 0:
                    return "VT";
                case 1:
                    _target = 0;
                    return ToStringHelper();
                case 2:
                    _target = 0;
                    return ToString();
                default:
                    throw new Exception();
            }
        }

        public String ToStringHelper()
        {
            _path += "->ToStringHelper";
            switch (_target)
            {
                case 0:
                    return "VT";
                case 1:
                    _target = 0;
                    return ToStringHelper();
                case 2:
                    _target = 0;
                    return ToString();
                default:
                    throw new Exception();
            }
        }

        private bool RunTests()
        {
            _target = 0;
            _path = null;
            Console.WriteLine(ToStringHelper() + " : " + _path);
            if (_path != "->ToStringHelper")
                return false;
            _target = 1;
            _path = null;
            Console.WriteLine(ToStringHelper() + " : " + _path);
            if (_path != "->ToStringHelper->ToStringHelper")
                return false;
            _target = 2;
            _path = null;
            Console.WriteLine(ToStringHelper() + " : " + _path);
            if (_path != "->ToStringHelper->ToString")
                return false;
            _target = 0;
            _path = null;
            Console.WriteLine(ToString() + " : " + _path);
            if (_path != "->ToString")
                return false;
            _target = 1;
            _path = null;
            Console.WriteLine(ToString() + " : " + _path);
            if (_path != "->ToString->ToStringHelper")
                return false;
            _target = 2;
            _path = null;
            Console.WriteLine(ToString() + " : " + _path);
            if (_path != "->ToString->ToString")
                return false;
            return true;
        }

        private static int Main()
        {
            if (new VT().RunTests())
            {
                Console.WriteLine("PASSED.");
                return 100;
            }
            Console.WriteLine("FAILED.");
            return 101;
        }
    }
}