/
debug-casts.cs
45 lines (40 loc) · 1.06 KB
/
debug-casts.cs
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
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public class Tests
{
public static int Main (string[] args) {
return TestDriver.RunTests (typeof (Tests), args);
}
public static int test_0_simple () {
object o = new object ();
try {
string s = (string)o;
return 1;
} catch (InvalidCastException ex) {
if (!ex.Message.Contains ("System.Object") || !ex.Message.Contains ("System.String"))
return 2;
}
return 0;
}
public static int test_0_complex_1 () {
object o = new object ();
try {
IEnumerable<object> ie = (IEnumerable<object>)o;
return 1;
} catch (InvalidCastException ex) {
if (!ex.Message.Contains ("System.Object") || !ex.Message.Contains ("System.Collections.Generic.IEnumerable`1[System.Object]"))
return 2;
}
return 0;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static object return_null () {
return null;
}
public static int test_0_complex_1_null () {
object o = return_null ();
IEnumerable<object> ie = (IEnumerable<object>)o;
return 0;
}
}