Author: gert
Date: 2007-10-15 04:16:16 -0400 (Mon, 15 Oct 2007)
New Revision: 87477

Added:
   trunk/gert/standalone/bug333696/
   trunk/gert/standalone/bug333696/default.build
   trunk/gert/standalone/bug333696/test.cs
Log:
Added test for bug #333696.


Added: trunk/gert/standalone/bug333696/default.build
===================================================================
--- trunk/gert/standalone/bug333696/default.build       2007-10-15 08:13:33 UTC 
(rev 87476)
+++ trunk/gert/standalone/bug333696/default.build       2007-10-15 08:16:16 UTC 
(rev 87477)
@@ -0,0 +1,53 @@
+<project name="bug333696" default="rebuild">
+       <target name="mono-2.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,NET_2_0,ONLY_2_0,MONO" />
+       </target>
+
+       <target name="net-2.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,NET_2_0,ONLY_2_0" />
+       </target>
+
+       <property name="frameworks" value="mono-2.0,net-2.0" />
+
+       <target name="clean">
+               <delete>
+                       <fileset>
+                               <include name="out" />
+                               <include name="test.exe" />
+                       </fileset>
+               </delete>
+       </target>
+
+       <target name="build">
+               <property name="original.targetframework" 
value="${nant.settings.currentframework}" />
+
+               <foreach property="framework" item="String" in="${frameworks}" 
delim=",">
+                       <if test="${framework::exists(framework)}">
+                               <property name="nant.settings.currentframework" 
value="${framework}" />
+                               <call 
target="${nant.settings.currentframework}" />
+                               <call target="run" />
+                               <call target="clean" />
+                       </if>
+               </foreach>
+
+               <property name="nant.settings.currentframework" 
value="${original.targetframework}" />
+       </target>
+
+       <target name="compile">
+               <csc target="exe" define="${csc.defines}" output="test.exe" 
warnaserror="true" warninglevel="4">
+                       <sources>
+                               <include name="test.cs" />
+                       </sources>
+                       <references>
+                               <include name="System.Windows.Forms.dll" />
+                       </references>
+               </csc>
+       </target>
+
+       <target name="run" depends="compile">
+               <exec program="test.exe" managed="true" output="out" />
+               <fail if="${file::exists('out')}" />
+       </target>
+
+       <target name="rebuild" depends="clean, build" />
+</project>


Property changes on: trunk/gert/standalone/bug333696/default.build
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/gert/standalone/bug333696/test.cs
===================================================================
--- trunk/gert/standalone/bug333696/test.cs     2007-10-15 08:13:33 UTC (rev 
87476)
+++ trunk/gert/standalone/bug333696/test.cs     2007-10-15 08:16:16 UTC (rev 
87477)
@@ -0,0 +1,43 @@
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+public class Testcase
+{
+       public static int [] Array = new int [] { 1, 2, 3, 4 };
+       private static readonly FieldInfo ArrayFI = typeof (Testcase).GetField 
("Array");
+       
+       static int Main ()
+       {
+               if (!DoLdelem ())
+                       return 1;
+               if (!DoStelem ())
+                       return 2;
+               return 0;
+       }
+       
+       static bool DoStelem ()
+       {
+               DynamicMethod dm = new DynamicMethod ("EmittedStelem", null, 
null, typeof (Testcase));
+               ILGenerator il = dm.GetILGenerator ();
+               il.Emit (OpCodes.Ldsfld, ArrayFI);
+               il.Emit (OpCodes.Ldc_I4_0);
+               il.Emit (OpCodes.Ldc_I4_0);
+               il.Emit (OpCodes.Stelem, typeof (int));
+               il.Emit (OpCodes.Ret);
+               dm.Invoke (null, null);
+               return (Array [0] == 0);
+       }
+       
+       static bool DoLdelem ()
+       {
+               DynamicMethod dm = new DynamicMethod ("EmittedLdelem", typeof 
(int), null, typeof (Testcase));
+               ILGenerator il = dm.GetILGenerator ();
+               il.Emit (OpCodes.Ldsfld, ArrayFI);
+               il.Emit (OpCodes.Ldc_I4_1);
+               il.Emit (OpCodes.Ldelem, typeof (int));
+               il.Emit (OpCodes.Ret);
+               int i = (int) dm.Invoke (null, null);
+               return (i == 2);
+       }
+}


Property changes on: trunk/gert/standalone/bug333696/test.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to