jaroslav@651: /** jaroslav@651: * Back 2 Browser Bytecode Translator jaroslav@651: * Copyright (C) 2012 Jaroslav Tulach jaroslav@650: * jaroslav@651: * This program is free software: you can redistribute it and/or modify jaroslav@651: * it under the terms of the GNU General Public License as published by jaroslav@651: * the Free Software Foundation, version 2 of the License. jaroslav@650: * jaroslav@651: * This program is distributed in the hope that it will be useful, jaroslav@651: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@651: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@651: * GNU General Public License for more details. jaroslav@650: * jaroslav@651: * You should have received a copy of the GNU General Public License jaroslav@651: * along with this program. Look for COPYING file in the top folder. jaroslav@651: * If not, see http://opensource.org/licenses/GPL-2.0. 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: }