[CI] ignore appdomain-unload-asmload.exe on interp and full-aot
[mono.git] / mono / tests / vararg.il
1 //
2 // vararg.il: Tests for varargs and refany instructions
3 //
4
5 .assembly extern mscorlib {
6 }
7
8 .assembly extern TestDriver {
9 }
10
11 .assembly 'vararg' {
12 }
13
14 .module 'vararg'
15
16 .class public auto ansi Tests extends [mscorlib]System.Object {
17
18         .method public static vararg void varargtest () cil managed {
19                 .maxstack 16
20                 .locals init (
21                         valuetype [mscorlib]System.ArgIterator it
22                 )
23
24                 ldloca.s it
25                 arglist
26                 call instance void [mscorlib]System.ArgIterator::.ctor (valuetype [mscorlib]System.RuntimeArgumentHandle)
27         L0:
28                 ldloca.s it
29                 call instance int32 [mscorlib]System.ArgIterator::GetRemainingCount ()
30                 ldc.i4.0
31                 ceq
32                 brtrue L1
33                 ldloca.s it
34                 call instance typedref [mscorlib]System.ArgIterator::GetNextArg ()
35                 call object [mscorlib]System.TypedReference::ToObject (typedref)
36                 call void [mscorlib]System.Console::WriteLine (object)
37                 br.s L0
38         L1:
39                 ret
40         }
41
42         // Test varargs
43         .method public static int32 test_0_varargs () cil managed {
44                 .maxstack 16
45
46                 ldc.i4.0
47                 ldc.i4.1
48                 call vararg void Tests::varargtest (..., int32, int32)
49                 ldc.i4.0
50                 ret
51         }               
52
53         .method public static vararg int32 varargtest_refany (int32 last) cil managed {
54                 .maxstack 16
55                 .locals init (
56                         valuetype [mscorlib]System.ArgIterator it,
57                         int32 sum
58                 )
59
60                 ldloca.s it
61                 arglist
62                 call instance void [mscorlib]System.ArgIterator::.ctor (valuetype [mscorlib]System.RuntimeArgumentHandle)
63                 ldc.i4.0
64                 stloc.s sum
65         L0:
66                 ldloca.s it
67                 call instance int32 [mscorlib]System.ArgIterator::GetRemainingCount ()
68                 ldc.i4.0
69                 ceq
70                 brtrue L1
71                 ldloca.s it
72                 call instance typedref [mscorlib]System.ArgIterator::GetNextArg ()
73                 ldloc.s sum
74                 call void [mscorlib]System.Console::WriteLine (int32)
75                 refanyval int32
76                 ldind.i4
77                 dup
78                 call void [mscorlib]System.Console::WriteLine (int32)
79                 ldloc.s sum
80                 add
81                 stloc.s sum
82                 br.s L0
83         L1:
84                 ldloc.s sum
85                 ret
86         }       
87
88         // Test varargs
89         .method public static int32 test_99_varargs_refany () cil managed {
90                 .maxstack 16
91
92                 ldc.i4 1
93                 ldc.i4 2
94                 ldc.i4 3
95                 ldc.i4 4
96                 ldc.i4 5
97                 ldc.i4 42
98                 ldc.i4 43
99                 call vararg int32 Tests::varargtest_refany (int32, ..., int32, int32, int32, int32, int32, int32)
100                 ret
101         }
102
103         // Test varargs
104         .method public static int32 test_0_varargs_refany_noargs () cil managed {
105                 .maxstack 16
106
107                 ldc.i4 1
108                 call vararg int32 Tests::varargtest_refany (int32)
109                 ret
110         }
111
112         .method public static int32 test_0_refanytest () cil managed {
113                 .maxstack 16
114                 .locals init (
115                         int32 sum,
116                         typedref ref
117                 )
118
119                 ldloca.s sum
120                 mkrefany int32
121                 stloc.s ref
122
123                 // Test refany with valid type
124                 ldloc.s ref
125                 refanyval int32
126                 ldloca.s sum
127                 ceq
128                 brfalse ERR1
129
130                 // Test refany with invalid type
131                 .try {
132                         ldloc.s ref
133                         refanyval int64
134                         pop
135                         leave ERR2
136                 }
137                 catch [mscorlib]System.InvalidCastException {
138                         pop
139                         leave L_LEAVE
140                 }
141         L_LEAVE:
142
143                 // Test refanytype
144                 ldloc.s ref
145                 refanytype
146                 call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle (valuetype [mscorlib]System.RuntimeTypeHandle)
147                 ldtoken int32
148                 call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle (valuetype [mscorlib]System.RuntimeTypeHandle)
149                 ceq
150                 brfalse ERR3
151
152                 ldc.i4.0
153                 ret
154         ERR1:
155                 ldc.i4.1
156                 ret
157         ERR2:
158                 ldc.i4.2
159                 ret
160         ERR3:
161                 ldc.i4.3
162                 ret
163         }
164
165         .method public static vararg float64 varargtest_refany_fp (float64 last) cil managed {
166                 .maxstack 16
167                 .locals init (
168                         valuetype [mscorlib]System.ArgIterator it,
169                         float64 sum
170                 )
171
172                 ldloca.s it
173                 arglist
174                 call instance void [mscorlib]System.ArgIterator::.ctor (valuetype [mscorlib]System.RuntimeArgumentHandle)
175         L0:
176                 ldloca.s it
177                 call instance int32 [mscorlib]System.ArgIterator::GetRemainingCount ()
178                 ldc.i4.0
179                 ceq
180                 brtrue L1
181                 ldloca.s it
182                 call instance typedref [mscorlib]System.ArgIterator::GetNextArg ()
183                 //ldloc.s sum
184                 //call void [mscorlib]System.Console::WriteLine (float64)
185                 refanyval float64
186                 ldind.r8
187                 //dup
188                 //call void [mscorlib]System.Console::WriteLine (float64)
189                 ldloc.s sum
190                 add
191                 stloc.s sum
192                 br.s L0
193         L1:
194                 ldloc.s sum
195                 ret
196         }       
197
198         .method public static int32 test_99_varargs_refany_fp () cil managed {
199                 .maxstack 16
200
201                 ldc.r8 1
202                 ldc.r8 2
203                 ldc.r8 3
204                 ldc.r8 4
205                 ldc.r8 5
206                 ldc.r8 42
207                 ldc.r8 43
208                 call vararg float64 Tests::varargtest_refany_fp (float64, ..., float64, float64, float64, float64, float64, float64)
209                 conv.i4
210                 ret
211         }
212
213         .method public static int32 Main () cil managed {
214                 .maxstack 16
215                 .entrypoint
216
217                 ldtoken Tests
218         call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
219         call int32 class [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type)
220         ret
221
222         }
223 }