01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.jjs.test;
17:
18: import com.google.gwt.junit.client.GWTTestCase;
19:
20: import java.util.Arrays;
21:
22: /**
23: * Tests the new JDK 1.5 varargs functionality.
24: *
25: */
26: public class VarargsTest extends GWTTestCase {
27:
28: public String getModuleName() {
29: return "com.google.gwt.dev.jjs.CompilerSuite";
30: }
31:
32: public void testVararg() {
33: String[] strings = new String[] { "1", "2", "3" };
34: String[] results = vararg("1", "2", "3");
35: assertTrue(Arrays.equals(results, strings));
36: }
37:
38: public void testVarargBoxing() {
39: int[] ints = new int[] { 1, 2, 3 };
40: int[] results = varargUnboxed(1, 2, 3);
41: assertTrue(Arrays.equals(results, ints));
42: int[] results2 = varargUnboxed(new Integer(1), 2,
43: new Integer(3));
44: assertTrue(Arrays.equals(ints, results2));
45: }
46:
47: private String[] vararg(String... args) {
48: return args;
49: }
50:
51: private int[] varargUnboxed(int... args) {
52: return args;
53: }
54: }
|