2 // load-exceptions.cs: Tests for loading missing types/methods/fields from IL
7 class Miss1 : Missing.Foo1 {
10 public class Tests : LoadMissing {
12 public delegate void TestDel ();
14 internal static int check_type_load (TestDel d) {
18 catch (TypeLoadException ex) {
19 //Console.WriteLine (ex.TypeName);
20 //Console.WriteLine (ex);
27 internal static int check_missing_method (TestDel d) {
31 catch (MissingMethodException ex) {
32 //Console.WriteLine (ex);
39 internal static int check_missing_field (TestDel d) {
43 catch (MissingFieldException ex) {
44 //Console.WriteLine (ex);
55 public static int test_0_call () {
56 return check_missing_method (new TestDel (missing_call));
59 public static int test_0_jmp () {
60 return check_missing_method (new TestDel (missing_jmp));
63 public static int test_0_ldftn () {
64 return check_missing_method (new TestDel (missing_ldftn));
68 // Object model instructions
71 public static int test_0_box () {
76 public static int test_0_callvirt () {
77 return check_missing_method (new TestDel (missing_callvirt));
80 public static int test_0_castclass () {
81 return check_type_load (new TestDel (missing_castclass));
84 public static int test_0_cpobj () {
85 return check_type_load (new TestDel (missing_cpobj));
88 public static int test_0_initobj () {
89 return check_type_load (new TestDel (missing_initobj));
92 public static int test_0_isinst () {
93 return check_type_load (new TestDel (missing_isinst));
96 public static int test_0_ldelem () {
101 public static int test_0_ldelema () {
106 public static int test_0_ldfld () {
107 return check_missing_field (new TestDel (missing_ldfld));
110 public static int test_0_ldflda () {
111 return check_missing_field (new TestDel (missing_ldflda));
114 public static int test_0_ldobj () {
119 public static int test_0_ldsfld () {
120 return check_missing_field (new TestDel (missing_ldsfld));
123 public static int test_0_ldsflda () {
124 return check_missing_field (new TestDel (missing_ldsflda));
127 public static int test_0_ldtoken_type () {
128 return check_type_load (new TestDel (missing_ldtoken_type));
131 public static int test_0_ldtoken_method () {
132 return check_missing_method (new TestDel (missing_ldtoken_method));
135 public static int test_0_ldtoken_field () {
136 return check_missing_field (new TestDel (missing_ldtoken_field));
139 public static int test_0_ldvirtftn () {
140 return check_missing_method (new TestDel (missing_ldvirtftn));
143 public static int test_0_mkrefany () {
148 public static int test_0_newarr () {
149 return check_type_load (new TestDel (missing_newarr));
152 public static int test_0_newobj () {
153 return check_missing_method (new TestDel (missing_newobj));
156 public static int test_0_refanyval () {
157 return check_type_load (new TestDel (missing_refanyval));
160 public static int test_0_sizeof () {
161 return check_type_load (new TestDel (missing_sizeof));
164 public static int test_0_stelem () {
169 public static int test_0_stfld () {
170 return check_missing_field (new TestDel (missing_stfld));
173 public static int test_0_stobj () {
178 public static int test_0_stsfld () {
179 return check_missing_field (new TestDel (missing_stsfld));
182 public static int test_0_unbox () {
183 return check_type_load (new TestDel (missing_unbox));
186 public static int test_0_unbox_any () {
187 return check_type_load (new TestDel (missing_unbox_any));
191 // Missing classes referenced from metadata
194 // FIXME: These do not work yet
196 public static int test_0_missing_local () {
200 catch (TypeLoadException ex) {
203 /* MS.NET doesn't throw an exception if a local is not found */
207 public static void missing_parent () {
211 public static int test_0_missing_parent () {
212 return check_type_load (new TestDel (missing_parent));
216 public static int Main () {
217 return TestDriver.RunTests (typeof (Tests));