2003-10-15 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Wed, 15 Oct 2003 20:58:09 +0000 (20:58 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 15 Oct 2003 20:58:09 +0000 (20:58 -0000)
* vararg.il: New file.

* Makefile.am: Added vararg.il.

svn path=/trunk/mono/; revision=19092

mono/tests/ChangeLog
mono/tests/Makefile.am
mono/tests/vararg.il [new file with mode: 0644]

index ab5ab5b76d5ba74d1c55ae1a69e1214dfc1d3f3f..6779ea2868d32740a7d4f4009e5b3156d710ee6f 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-15  Zoltan Varga  <vargaz@freemail.hu>
+
+       * vararg.il: New file.
+
+       * Makefile.am: Added vararg.il.
+
 2003-10-13  Bernie Solomon  <bernard@ugsolutions.com>
 
        * Makefile.am: fix so it works if builddir != srcdir
index b8618865f0852cb43be5184866fb11b66ce110dd..125867a1333172628ce3db6602c85eb5514740e8 100644 (file)
@@ -181,6 +181,7 @@ TEST_IL_SRC=                        \
        initblkTest.il          \
        even-odd.il             \
        qt-instance.il          \
+       vararg.il                       \
        bug-29859.il
 
 
diff --git a/mono/tests/vararg.il b/mono/tests/vararg.il
new file mode 100644 (file)
index 0000000..f501a8c
--- /dev/null
@@ -0,0 +1,161 @@
+//
+// vararg.il: Tests for varargs and refany instructions
+//
+
+.assembly extern mscorlib {
+}
+
+.assembly extern TestDriver {
+}
+
+.assembly 'vararg' {
+}
+
+.module 'vararg'
+
+.class public auto ansi Tests extends [mscorlib]System.Object {
+
+       .method public static vararg void varargtest () cil managed {
+               .maxstack 16
+               .locals init (
+                       valuetype [mscorlib]System.ArgIterator it
+               )
+
+               ldloca.s it
+               arglist
+               call instance void [mscorlib]System.ArgIterator::.ctor (valuetype [mscorlib]System.RuntimeArgumentHandle)
+       L0:
+               ldloca.s it
+               call instance int32 [mscorlib]System.ArgIterator::GetRemainingCount ()
+               ldc.i4.0
+               ceq
+               brtrue L1
+               ldloca.s it
+               call instance typedref [mscorlib]System.ArgIterator::GetNextArg ()
+               call object [mscorlib]System.TypedReference::ToObject (typedref)
+               call void [mscorlib]System.Console::WriteLine (object)
+               br.s L0
+       L1:
+               ret
+       }
+
+       // Test varargs
+       .method public static int32 test_0_varargs () cil managed {
+               .maxstack 16
+
+               ldc.i4.0
+               ldc.i4.1
+               call vararg void Tests::varargtest (..., int32, int32)
+               ldc.i4.0
+               ret
+       }               
+
+       .method public static vararg int32 varargtest_refany () cil managed {
+               .maxstack 16
+               .locals init (
+                       valuetype [mscorlib]System.ArgIterator it,
+                       int32 sum
+               )
+
+               ldloca.s it
+               arglist
+               call instance void [mscorlib]System.ArgIterator::.ctor (valuetype [mscorlib]System.RuntimeArgumentHandle)
+               ldc.i4.0
+               stloc.s sum
+       L0:
+               ldloca.s it
+               call instance int32 [mscorlib]System.ArgIterator::GetRemainingCount ()
+               ldc.i4.0
+               ceq
+               brtrue L1
+               ldloca.s it
+               call instance typedref [mscorlib]System.ArgIterator::GetNextArg ()
+               ldloc.s sum
+               call void [mscorlib]System.Console::WriteLine (int32)
+               refanyval int32
+               ldind.i4
+               dup
+               call void [mscorlib]System.Console::WriteLine (int32)
+               ldloc.s sum
+               add
+               stloc.s sum
+               br.s L0
+       L1:
+               ldloc.s sum
+               ret
+       }       
+
+       // Test varargs
+       .method public static int32 test_85_varargs_refany () cil managed {
+               .maxstack 16
+
+               ldc.i4 42
+               ldc.i4 43
+               call vararg int32 Tests::varargtest_refany (..., int32, int32)
+               ret
+       }
+
+       .method public static int32 test_0_refanytest () cil managed {
+               .maxstack 16
+               .locals init (
+                       int32 sum,
+                       typedref ref
+               )
+
+               ldloca.s sum
+               mkrefany int32
+               stloc.s ref
+
+               // Test refany with valid type
+               ldloc.s ref
+               refanyval int32
+               ldloca.s sum
+               ceq
+               brfalse ERR1
+
+               // Test refany with invalid type
+               .try {
+                       ldloc.s ref
+                       refanyval int64
+                       pop
+                       leave ERR2
+               }
+               catch [mscorlib]System.InvalidCastException {
+                       pop
+                       leave L_LEAVE
+               }
+       L_LEAVE:
+
+               // Test refanytype
+               ldloc.s ref
+               refanytype
+               call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle (valuetype [mscorlib]System.RuntimeTypeHandle)
+               ldtoken int32
+               call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle (valuetype [mscorlib]System.RuntimeTypeHandle)
+               ceq
+               brfalse ERR3
+
+               ldc.i4.0
+               ret
+       ERR1:
+               ldc.i4.1
+               ret
+       ERR2:
+               ldc.i4.2
+               ret
+       ERR3:
+               ldc.i4.3
+               ret
+       }
+
+       .method public static int32 Main () cil managed {
+               .maxstack 16
+               .entrypoint
+
+               ldtoken Tests
+        call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
+        call int32 class [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type)
+        ret
+
+       }
+}
\ No newline at end of file