Permalink
Browse files

Test case for bug #80487.

svn path=/trunk/mono/; revision=71188
  • Loading branch information...
1 parent c3d2fd0 commit 10ba6081d6f3b16e058ad28aadb8608ed8fae426 @illupus illupus committed Jan 17, 2007
Showing with 57 additions and 1 deletion.
  1. +2 −1 mono/tests/Makefile.am
  2. +23 −0 mono/tests/module-cctor-loader.2.cs
  3. +32 −0 mono/tests/module-cctor.il
View
@@ -274,13 +274,14 @@ TEST_CS2_SRC = \
catch-generics.2.cs \
event-get.2.cs \
safehandle.2.cs \
+ module-cctor-loader.2.cs \
bug-80392.2.cs
TEST_IL2_SRC = find-method.2.il
# pre-requisite test sources: files that are not test themselves
# but that need to be compiled
-PREREQ_IL_SRC=event-il.il
+PREREQ_IL_SRC=event-il.il module-cctor.il
PREREQ_CS_SRC=
PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe)
@@ -0,0 +1,23 @@
+using System;
+
+public class Program
+{
+ public static int Main()
+ {
+ System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom("module-cctor.exe");
+ Console.WriteLine("assembly loaded");
+ Type type = asm.GetType("NS.TestClass", true);
+ Console.WriteLine("got type 'NS.TestClass'");
+
+ System.Reflection.FieldInfo field = type.GetField("TestField");
+ Console.WriteLine("about to get value of 'TestField'");
+ Console.WriteLine("got field 'TestField'");
+ int val = (int)field.GetValue(null);
+ Console.WriteLine("Value of field: " + val);
+ if (val == 1)
+ return 0;
+ return 1;
+ }
+}
+
+
View
@@ -0,0 +1,32 @@
+.assembly TestDll { }
+.assembly extern mscorlib { }
+
+.method assembly specialname rtspecialname static
+ void .cctor() cil managed
+{
+ ldc.i4 1
+ stsfld int32 NS.TestClass::TestField
+ ldstr "Module contructor executed"
+ call void [mscorlib]System.Console::WriteLine(string)
+ ret
+}
+
+.namespace NS
+{
+ .class public TestClass extends [mscorlib]System.Object
+ {
+ .field public static int32 TestField
+
+ .method public static void TestMethod() cil managed
+ {
+ ldstr "TestMethod executed"
+ call void [mscorlib]System.Console::WriteLine(string)
+ ret
+ }
+ .method public static void Main() cil managed
+ {
+ .entrypoint
+ ret
+ }
+ }
+}

0 comments on commit 10ba608

Please sign in to comment.