Skip to content

Commit

Permalink
Test case for bug #80487.
Browse files Browse the repository at this point in the history
svn path=/trunk/mono/; revision=71188
  • Loading branch information
illupus committed Jan 17, 2007
1 parent c3d2fd0 commit 10ba608
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mono/tests/Makefile.am
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -274,13 +274,14 @@ TEST_CS2_SRC = \
catch-generics.2.cs \ catch-generics.2.cs \
event-get.2.cs \ event-get.2.cs \
safehandle.2.cs \ safehandle.2.cs \
module-cctor-loader.2.cs \
bug-80392.2.cs bug-80392.2.cs


TEST_IL2_SRC = find-method.2.il TEST_IL2_SRC = find-method.2.il


# pre-requisite test sources: files that are not test themselves # pre-requisite test sources: files that are not test themselves
# but that need to be compiled # but that need to be compiled
PREREQ_IL_SRC=event-il.il PREREQ_IL_SRC=event-il.il module-cctor.il
PREREQ_CS_SRC= PREREQ_CS_SRC=


PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe) PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe)
Expand Down
23 changes: 23 additions & 0 deletions mono/tests/module-cctor-loader.2.cs
Original file line number Original file line Diff line number Diff line change
@@ -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;
}
}


32 changes: 32 additions & 0 deletions mono/tests/module-cctor.il
Original file line number Original file line Diff line number Diff line change
@@ -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.