BC_arraylength.java revision 12657:6ef01bd40ce2
1/*
2 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23package org.graalvm.compiler.jtt.bytecode;
24
25import org.junit.Test;
26
27import org.graalvm.compiler.jtt.JTTTest;
28
29/*
30 */
31public class BC_arraylength extends JTTTest {
32
33    static byte[] array0 = {1, 2};
34    static char[] array1 = {'a', 'b', 'c', 'd'};
35    static short[] array2 = {1, 2, 3, 4, 5, 6};
36    static int[] array3 = {1, 2, 3};
37    static long[] array4 = {1L, 2L, 3L, 4L};
38    static float[] array5 = {0.1f, 0.2f};
39    static double[] array6 = {0.1, 0.2, 0.3, 0.4};
40    static Object[] array7 = new Object[5];
41    static boolean[] array8 = {false, true, false};
42
43    public static int testByte(byte[] arg) {
44        return arg.length;
45    }
46
47    public static int testChar(char[] arg) {
48        return arg.length;
49    }
50
51    public static int testShort(short[] arg) {
52        return arg.length;
53    }
54
55    public static int testInt(int[] arg) {
56        return arg.length;
57    }
58
59    public static int testLong(long[] arg) {
60        return arg.length;
61    }
62
63    public static int testFloat(float[] arg) {
64        return arg.length;
65    }
66
67    public static int testDouble(double[] arg) {
68        return arg.length;
69    }
70
71    public static int testObject(Object[] arg) {
72        return arg.length;
73    }
74
75    public static int testBoolean(boolean[] arg) {
76        return arg.length;
77    }
78
79    @Test
80    public void run0() throws Throwable {
81        runTest("testByte", array0);
82    }
83
84    @Test
85    public void run1() throws Throwable {
86        runTest("testChar", array1);
87    }
88
89    @Test
90    public void run2() throws Throwable {
91        runTest("testShort", array2);
92    }
93
94    @Test
95    public void run3() throws Throwable {
96        runTest("testInt", array3);
97    }
98
99    @Test
100    public void run4() throws Throwable {
101        runTest("testLong", array4);
102    }
103
104    @Test
105    public void run5() throws Throwable {
106        runTest("testFloat", array5);
107    }
108
109    @Test
110    public void run6() throws Throwable {
111        runTest("testDouble", array6);
112    }
113
114    @Test
115    public void run7() throws Throwable {
116        runTest("testObject", new Object[]{array7});
117    }
118
119    @Test
120    public void run8() throws Throwable {
121        runTest("testBoolean", array8);
122    }
123
124}
125