2 // load-exceptions.cs: Tests for loading missing types/methods/fields from IL
8 class Miss1 : Missing.Foo1 {
11 public class Tests : LoadMissing {
13 public delegate void TestDel ();
15 internal static int check_type_load (TestDel d) {
19 catch (TypeLoadException ex) {
20 //Console.WriteLine (ex.TypeName);
21 //Console.WriteLine (ex);
28 internal static int check_missing_method (TestDel d) {
32 catch (MissingMethodException ex) {
33 //Console.WriteLine (ex);
40 internal static int check_file_not_found (TestDel d){
43 } catch (FileNotFoundException ex){
49 internal static int check_missing_field (TestDel d) {
53 catch (MissingFieldException ex) {
54 //Console.WriteLine (ex);
66 public static int test_0_call () {
67 return check_missing_method (new TestDel (missing_call));
70 public static int test_0_jmp () {
71 return check_missing_method (new TestDel (missing_jmp));
74 public static int test_0_ldftn () {
75 return check_missing_method (new TestDel (missing_ldftn));
79 // Object model instructions
82 public static int test_0_box () {
87 public static int test_0_callvirt () {
88 return check_missing_method (new TestDel (missing_callvirt));
91 public static int test_0_castclass () {
92 return check_type_load (new TestDel (missing_castclass));
95 public static int test_0_cpobj () {
96 return check_type_load (new TestDel (missing_cpobj));
99 public static int test_0_missing_type_on_parameter () {
100 return check_type_load (new TestDel (missing_external_type_reference_on_parameter));
102 public static int test_0_initobj () {
103 return check_type_load (new TestDel (missing_initobj));
106 public static int test_0_isinst () {
107 return check_type_load (new TestDel (missing_isinst));
110 public static int test_0_ldelem () {
115 public static int test_0_ldelema () {
120 public static int test_0_ldfld () {
121 return check_missing_field (new TestDel (missing_ldfld));
124 public static int test_0_ldflda () {
125 return check_missing_field (new TestDel (missing_ldflda));
128 public static int test_0_ldobj () {
133 public static int test_0_ldsfld () {
134 return check_missing_field (new TestDel (missing_ldsfld));
137 public static int test_0_ldsflda () {
138 return check_missing_field (new TestDel (missing_ldsflda));
141 public static int test_0_ldtoken_type () {
142 return check_type_load (new TestDel (missing_ldtoken_type));
145 public static int test_0_ldtoken_method () {
146 return check_missing_method (new TestDel (missing_ldtoken_method));
149 public static int test_0_ldtoken_field () {
150 return check_missing_field (new TestDel (missing_ldtoken_field));
153 public static int test_0_ldvirtftn () {
154 return check_missing_method (new TestDel (missing_ldvirtftn));
157 public static int test_0_mkrefany () {
162 public static int test_0_newarr () {
163 return check_type_load (new TestDel (missing_newarr));
166 public static int test_0_newobj () {
167 return check_missing_method (new TestDel (missing_newobj));
170 public static int test_0_refanyval () {
171 return check_type_load (new TestDel (missing_refanyval));
174 public static int test_0_sizeof () {
175 return check_type_load (new TestDel (missing_sizeof));
178 public static int test_0_stelem () {
183 public static int test_0_stfld () {
184 return check_missing_field (new TestDel (missing_stfld));
187 public static int test_0_stobj () {
192 public static int test_0_stsfld () {
193 return check_missing_field (new TestDel (missing_stsfld));
196 public static int test_0_unbox () {
197 return check_type_load (new TestDel (missing_unbox));
200 public static int test_0_unbox_any () {
201 return check_type_load (new TestDel (missing_unbox_any));
205 // Bummer: we regressed! I should have put this before
206 public static int test_0_missing_assembly_in_fieldref () {
207 return check_file_not_found (new TestDel (missing_assembly_in_fieldref));
211 public static int test_0_missing_assembly_in_call () {
212 return check_missing_method (new TestDel (missing_assembly_in_call));
215 public static int test_0_missing_assembly_in_newobj () {
216 return check_missing_method (new TestDel (missing_assembly_in_newobj));
220 // Missing classes referenced from metadata
223 // FIXME: These do not work yet
225 public static int test_0_missing_local () {
229 catch (TypeLoadException ex) {
232 /* MS.NET doesn't throw an exception if a local is not found */
236 public static void missing_parent () {
240 public static int test_0_missing_parent () {
241 return check_type_load (new TestDel (missing_parent));
245 public static int Main () {
246 return TestDriver.RunTests (typeof (Tests));