Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-682.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 43d6f1d10e8a68685f498bf7096a82fecac8a070 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;

public class broken_cast
{
	public static void report (string str)
	{
		throw new Exception (str);
	}

	public static void conv_ovf_i (long val, bool shouldThrow)
	{
		try {
			System.IntPtr x = (System.IntPtr) val;
			if (shouldThrow)
				report (String.Format ("conv_ovf_i did not throw for {0} ", val));
		} catch (OverflowException exception) {
			if (!shouldThrow)
				report (String.Format ("conv_ovf_i did throw for {0}", val));
		}
	}

	public static void conv_ovf_i_un (long val, bool shouldThrow)
	{
		try {
			System.IntPtr x = (System.IntPtr) val;
			if (shouldThrow)
				report (String.Format ("conv_ovf_i_un did not throw for {0} ", val));
		} catch (OverflowException exception) {
			if (!shouldThrow)
				report (String.Format ("conv_ovf_i_un did throw for {0}", val));
		}
	}

	public static void conv_ovf_u (long val, bool shouldThrow)
	{
		try {
			System.IntPtr x = (System.IntPtr) val;
			if (shouldThrow)
				report (String.Format ("conv_ovf_u did not throw for {0} ", val));
		} catch (OverflowException exception) {
			if (!shouldThrow)
				report (String.Format ("conv_ovf_u did throw for {0}", val));
		}
	}

	public static void conv_ovf_u_un (long val, bool shouldThrow)
	{
		try {
			System.IntPtr x = (System.IntPtr) val;
			if (shouldThrow)
				report (String.Format ("conv_ovf_u_un did not throw for {0} ", val));
		} catch (OverflowException exception) {
			if (!shouldThrow)
				report (String.Format ("conv_ovf_u_un did throw for {0}", val));
		}
	}

	public static int Main ()
	{
		long ok_number = 9;
		long negative = -1;
		long biggerThanI4 = int.MaxValue;
		++biggerThanI4;
		long smallerThanI4 = int.MinValue;
		--smallerThanI4;
		long biggerThanU4 = uint.MaxValue;
		++biggerThanU4;

		bool is32bits = IntPtr.Size == 4;
		int i = 1;

		try {
			conv_ovf_i (ok_number, false);
			++i;
			conv_ovf_i (negative, false);
//			++i;
//			conv_ovf_i (biggerThanI4, true && is32bits);
//			++i;
//			conv_ovf_i (smallerThanI4, true && is32bits);
//			++i;
//			conv_ovf_i (biggerThanU4, true && is32bits);

			++i;
			conv_ovf_i_un (ok_number, false);
			++i;
			conv_ovf_i_un (negative, false);
			++i;
//			conv_ovf_i_un (biggerThanI4, true && is32bits);
//			++i;
//			conv_ovf_i_un (smallerThanI4, true && is32bits);
//			++i;
//			conv_ovf_i_un (biggerThanU4, true && is32bits);

			++i;
			conv_ovf_u (ok_number, false);
			++i;
			conv_ovf_u (negative, false);
//			++i;
//			conv_ovf_u (biggerThanI4, true && is32bits);
//			++i;
//			conv_ovf_u (smallerThanI4, true && is32bits);
//			++i;
//			conv_ovf_u (biggerThanU4, true && is32bits);

			++i;
			conv_ovf_u_un (ok_number, false);
			++i;
			conv_ovf_u_un (negative, false);
//			++i;
//			conv_ovf_u_un (biggerThanI4, true && is32bits);
//			++i;
//			conv_ovf_u_un (smallerThanI4, true && is32bits);
//			++i;
//			conv_ovf_u_un (biggerThanU4, true && is32bits);

			return 0;
		} catch (Exception e) {
			Console.WriteLine (e);
			return i;
		}
	}

}