jaroslav@650: /* jaroslav@650: * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. jaroslav@650: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@650: * jaroslav@650: * This code is free software; you can redistribute it and/or modify it jaroslav@650: * under the terms of the GNU General Public License version 2 only, as jaroslav@650: * published by the Free Software Foundation. Oracle designates this jaroslav@650: * particular file as subject to the "Classpath" exception as provided jaroslav@650: * by Oracle in the LICENSE file that accompanied this code. jaroslav@650: * jaroslav@650: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@650: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@650: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@650: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@650: * accompanied this code). jaroslav@650: * jaroslav@650: * You should have received a copy of the GNU General Public License version jaroslav@650: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@650: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@650: * jaroslav@650: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@650: * or visit www.oracle.com if you need additional information or have any jaroslav@650: * questions. jaroslav@650: */ jaroslav@650: package org.apidesign.bck2brwsr.emul.reflect; jaroslav@650: jaroslav@650: import java.lang.reflect.Method; jaroslav@650: import java.util.Enumeration; jaroslav@650: import org.testng.annotations.Test; jaroslav@650: jaroslav@650: /** jaroslav@650: * jaroslav@650: * @author Jaroslav Tulach jaroslav@650: */ jaroslav@650: public class MethodImplTest { jaroslav@650: jaroslav@650: public MethodImplTest() { jaroslav@650: } jaroslav@650: jaroslav@650: public static String[] arr(String... arr) { jaroslav@650: return arr; jaroslav@650: } jaroslav@650: jaroslav@650: @Test jaroslav@650: public void testSignatureForMethodWithAnArray() throws NoSuchMethodException { jaroslav@650: Method m = MethodImplTest.class.getMethod("arr", String[].class); jaroslav@650: String sig = MethodImpl.toSignature(m); jaroslav@650: int sep = sig.indexOf("__"); jaroslav@650: assert sep > 0 : "Separator found " + sig; jaroslav@650: jaroslav@650: Enumeration en = MethodImpl.signatureParser(sig.substring(sep + 2)); jaroslav@650: jaroslav@650: assert en.nextElement() == m.getReturnType() : "Return type is the same"; jaroslav@650: assert en.nextElement() == m.getParameterTypes()[0] : "1st param type is the same"; jaroslav@650: } jaroslav@650: }