try to fix VarArgTest

Accoring to spec array of class.getMethods() is not sorted, so we can't just call
getMethods()[0] to get desired method.
This commit is contained in:
Stepan Koltsov
2011-11-25 22:31:29 +04:00
parent 0bd0932282
commit a6eeb01b64
3 changed files with 23 additions and 8 deletions
@@ -7,10 +7,12 @@ import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetNamespace;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.parsing.JetParsingTest;
import org.junit.Assert;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -157,7 +159,21 @@ public abstract class CodegenTestCase extends JetLiteFixture {
protected Method generateFunction() {
Class aClass = generateNamespaceClass();
try {
return aClass.getMethods()[0];
Method r = null;
for (Method method : aClass.getMethods()) {
if (method.getDeclaringClass().equals(Object.class)) {
continue;
}
if (r != null) {
throw new AssertionError("more then one public method in class " + aClass);
}
r = method;
}
if (r == null)
throw new AssertionError();
return r;
} catch (Error e) {
System.out.println(generateToText());
throw e;