1dcdee5c229474a6eefb7a561999511c7ce1eac0
[cacao.git] / tests / regression / native / testarguments.java
1 /* tests/native/testarguments.java - tests argument passing
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Thalinger
28
29    $Id: testarguments.java 3523 2005-10-28 19:56:29Z twisti $
30
31 */
32
33
34 import java.util.*;
35
36 public class testarguments {
37     static Random r;
38
39     public static native void nisub(int a, int b, int c, int d, int e,
40                                     int f, int g, int h, int i, int j,
41                                     int k, int l, int m, int n, int o);
42
43     public static native void nlsub(long a, long b, long c, long d, long e,
44                                     long f, long g, long h, long i, long j,
45                                     long k, long l, long m, long n, long o);
46
47     public static native void nfsub(float a, float b, float c, float d, float e,
48                                     float f, float g, float h, float i, float j,
49                                     float k, float l, float m, float n, float o);
50
51     public static native void ndsub(double a, double b, double c, double d, double e,
52                                     double f, double g, double h, double i, double j,
53                                     double k, double l, double m, double n, double o);
54
55     public static void main(String[] argv) {
56         r = new Random(0);
57
58         System.loadLibrary("testarguments");
59
60         itest();
61         ltest();
62         ftest();
63         dtest();
64     }
65
66     static void itest() {
67         pln("testing int --------------------------------------------------");
68
69         isub(0x11111111, 0x22222222, 0x33333333, 0x44444444, 0x55555555,
70              0x66666666, 0x77777777, 0x88888888, 0x99999999, 0xaaaaaaaa,
71              0xbbbbbbbb, 0xcccccccc, 0xdddddddd, 0xeeeeeeee, 0xffffffff);
72
73         pln();
74     }
75
76     static void ltest() {
77         pln("testing long -------------------------------------------------");
78
79         lsub(0x1111111111111111L, 0x2222222222222222L, 0x3333333333333333L,
80              0x4444444444444444L, 0x5555555555555555L, 0x6666666666666666L,
81              0x7777777777777777L, 0x8888888888888888L, 0x9999999999999999L,
82              0xaaaaaaaaaaaaaaaaL, 0xbbbbbbbbbbbbbbbbL, 0xccccccccccccccccL,
83              0xddddddddddddddddL, 0xeeeeeeeeeeeeeeeeL, 0xffffffffffffffffL);
84
85         pln();
86     }
87
88     static void ftest() {
89         pln("testing float ------------------------------------------------");
90
91         fsub(i2f(0x11111111), i2f(0x22222222), i2f(0x33333333),
92              i2f(0x44444444), i2f(0x55555555), i2f(0x66666666),
93              i2f(0x77777777), i2f(0x88888888), i2f(0x99999999),
94              i2f(0xaaaaaaaa), i2f(0xbbbbbbbb), i2f(0xcccccccc),
95              i2f(0xdddddddd), i2f(0xeeeeeeee), i2f(0xffffffff));
96
97         pln();
98     }
99
100     static void dtest() {
101         pln("testing double -----------------------------------------------");
102
103         dsub(l2d(0x1111111111111111L), l2d(0x2222222222222222L),
104              l2d(0x3333333333333333L), l2d(0x4444444444444444L),
105              l2d(0x5555555555555555L), l2d(0x6666666666666666L),
106              l2d(0x7777777777777777L), l2d(0x8888888888888888L),
107              l2d(0x9999999999999999L), l2d(0xaaaaaaaaaaaaaaaaL),
108              l2d(0xbbbbbbbbbbbbbbbbL), l2d(0xccccccccccccccccL),
109              l2d(0xddddddddddddddddL), l2d(0xeeeeeeeeeeeeeeeeL),
110              l2d(0xffffffffffffffffL));
111     }
112
113
114     // test java-java argument passing
115
116     public static void isub(int a, int b, int c, int d, int e,
117                             int f, int g, int h, int i, int j,
118                             int k, int l, int m, int n, int o) {
119         p("java-java  :");
120
121         p(a); p(b); p(c); p(d); p(e);
122         p(f); p(g); p(h); p(i); p(j);
123         p(k); p(l); p(m); p(n); p(o);
124
125         pln();
126
127         nisub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
128     }
129
130     public static void lsub(long a, long b, long c, long d, long e,
131                             long f, long g, long h, long i, long j,
132                             long k, long l, long m, long n, long o) {
133         p("java-java  :");
134
135         p(a); p(b); p(c); p(d); p(e);
136         p(f); p(g); p(h); p(i); p(j);
137         p(k); p(l); p(m); p(n); p(o);
138
139         pln();
140
141         nlsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
142     }
143
144     public static void fsub(float a, float b, float c, float d, float e,
145                             float f, float g, float h, float i, float j,
146                             float k, float l, float m, float n, float o) {
147         p("java-java  :");
148
149         p(a); p(b); p(c); p(d); p(e);
150         p(f); p(g); p(h); p(i); p(j);
151         p(k); p(l); p(m); p(n); p(o);
152
153         pln();
154
155         nfsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
156     }
157
158     public static void dsub(double a, double b, double c, double d, double e,
159                             double f, double g, double h, double i, double j,
160                             double k, double l, double m, double n, double o) {
161         p("java-java  :");
162
163         p(a); p(b); p(c); p(d); p(e);
164         p(f); p(g); p(h); p(i); p(j);
165         p(k); p(l); p(m); p(n); p(o);
166
167         pln();
168
169         ndsub(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
170     }
171
172
173     // test native-java argument passing
174
175     public static void jisub(int a, int b, int c, int d, int e,
176                              int f, int g, int h, int i, int j,
177                              int k, int l, int m, int n, int o) {
178         p("native-java:");
179
180         p(a); p(b); p(c); p(d); p(e);
181         p(f); p(g); p(h); p(i); p(j);
182         p(k); p(l); p(m); p(n); p(o);
183
184         pln();
185     }
186
187     public static void jlsub(long a, long b, long c, long d, long e,
188                              long f, long g, long h, long i, long j,
189                              long k, long l, long m, long n, long o) {
190         p("native-java:");
191
192         p(a); p(b); p(c); p(d); p(e);
193         p(f); p(g); p(h); p(i); p(j);
194         p(k); p(l); p(m); p(n); p(o);
195
196         pln();
197     }
198
199     public static void jfsub(float a, float b, float c, float d, float e,
200                              float f, float g, float h, float i, float j,
201                              float k, float l, float m, float n, float o) {
202         p("native-java:");
203
204         p(a); p(b); p(c); p(d); p(e);
205         p(f); p(g); p(h); p(i); p(j);
206         p(k); p(l); p(m); p(n); p(o);
207
208         pln();
209     }
210
211     public static void jdsub(double a, double b, double c, double d, double e,
212                              double f, double g, double h, double i, double j,
213                              double k, double l, double m, double n, double o) {
214         p("native-java:");
215
216         p(a); p(b); p(c); p(d); p(e);
217         p(f); p(g); p(h); p(i); p(j);
218         p(k); p(l); p(m); p(n); p(o);
219
220         pln();
221     }
222
223     static float i2f(int i) {
224         return Float.intBitsToFloat(i);
225     }
226
227     static double l2d(long l) {
228         return Double.longBitsToDouble(l);
229     }
230
231     static void p(String s) { System.out.print(s); }
232
233     static void p(int i) {
234         System.out.print(" 0x" + Integer.toHexString(i));
235     }
236
237     static void p(long l) {
238         System.out.print(" 0x" + Long.toHexString(l));
239     }
240
241     static void p(float f) {
242         p(Float.floatToIntBits(f));
243     }
244
245     static void p(double d) {
246         p(Double.doubleToLongBits(d));
247     }
248
249     static void pln() { System.out.println(); }
250     static void pln(String s) { System.out.println(s); }
251 }