jaroslav@650
|
1 |
/*
|
jaroslav@650
|
2 |
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
|
jaroslav@650
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
jaroslav@650
|
4 |
*
|
jaroslav@650
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
jaroslav@650
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
jaroslav@650
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
jaroslav@650
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
jaroslav@650
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
jaroslav@650
|
10 |
*
|
jaroslav@650
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
jaroslav@650
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
jaroslav@650
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
jaroslav@650
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
jaroslav@650
|
15 |
* accompanied this code).
|
jaroslav@650
|
16 |
*
|
jaroslav@650
|
17 |
* You should have received a copy of the GNU General Public License version
|
jaroslav@650
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
jaroslav@650
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
jaroslav@650
|
20 |
*
|
jaroslav@650
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
jaroslav@650
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
jaroslav@650
|
23 |
* questions.
|
jaroslav@650
|
24 |
*/
|
jaroslav@650
|
25 |
package org.apidesign.bck2brwsr.emul.reflect;
|
jaroslav@650
|
26 |
|
jaroslav@650
|
27 |
import java.lang.reflect.Method;
|
jaroslav@650
|
28 |
import java.util.Enumeration;
|
jaroslav@650
|
29 |
import org.testng.annotations.Test;
|
jaroslav@650
|
30 |
|
jaroslav@650
|
31 |
/**
|
jaroslav@650
|
32 |
*
|
jaroslav@650
|
33 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jaroslav@650
|
34 |
*/
|
jaroslav@650
|
35 |
public class MethodImplTest {
|
jaroslav@650
|
36 |
|
jaroslav@650
|
37 |
public MethodImplTest() {
|
jaroslav@650
|
38 |
}
|
jaroslav@650
|
39 |
|
jaroslav@650
|
40 |
public static String[] arr(String... arr) {
|
jaroslav@650
|
41 |
return arr;
|
jaroslav@650
|
42 |
}
|
jaroslav@650
|
43 |
|
jaroslav@650
|
44 |
@Test
|
jaroslav@650
|
45 |
public void testSignatureForMethodWithAnArray() throws NoSuchMethodException {
|
jaroslav@650
|
46 |
Method m = MethodImplTest.class.getMethod("arr", String[].class);
|
jaroslav@650
|
47 |
String sig = MethodImpl.toSignature(m);
|
jaroslav@650
|
48 |
int sep = sig.indexOf("__");
|
jaroslav@650
|
49 |
assert sep > 0 : "Separator found " + sig;
|
jaroslav@650
|
50 |
|
jaroslav@650
|
51 |
Enumeration<Class> en = MethodImpl.signatureParser(sig.substring(sep + 2));
|
jaroslav@650
|
52 |
|
jaroslav@650
|
53 |
assert en.nextElement() == m.getReturnType() : "Return type is the same";
|
jaroslav@650
|
54 |
assert en.nextElement() == m.getParameterTypes()[0] : "1st param type is the same";
|
jaroslav@650
|
55 |
}
|
jaroslav@650
|
56 |
} |