Remove testing Kotlin signature from WriteSignatureTest
This commit is contained in:
@@ -2,5 +2,4 @@ fun never(): Array<java.lang.CharSequence> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::never
|
||||
// jvm signature: ()[Ljava/lang/CharSequence;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[Mjava/lang/CharSequence; // TODO: need to skip kotlin signature
|
||||
// generic signature: null
|
||||
@@ -3,4 +3,3 @@ fun never(): Array<Int> = throw Exception()
|
||||
// method: _DefaultPackage::never
|
||||
// jvm signature: ()[Ljava/lang/Integer;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[Ljet/Int; // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -3,4 +3,3 @@ fun cc(): Comparable<java.lang.CharSequence>? = null
|
||||
// method: _DefaultPackage::cc
|
||||
// jvm signature: ()Ljava/lang/Comparable;
|
||||
// generic signature: ()Ljava/lang/Comparable<Ljava/lang/CharSequence;>;
|
||||
// kotlin signature: ()?Ljava/lang/Comparable<Mjava/lang/CharSequence;>;
|
||||
|
||||
@@ -2,5 +2,4 @@ fun key(): Int = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::key
|
||||
// jvm signature: ()I
|
||||
// generic signature: null
|
||||
// kotlin signature: ()I // TODO: make null
|
||||
// generic signature: null
|
||||
@@ -2,5 +2,4 @@ fun never(): IntArray = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::never
|
||||
// jvm signature: ()[I
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[I // TODO: need to skip kotlin signature
|
||||
// generic signature: null
|
||||
@@ -2,5 +2,4 @@ fun sometimes(): Int? = null
|
||||
|
||||
// method: _DefaultPackage::sometimes
|
||||
// jvm signature: ()Ljava/lang/Integer;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()?Ljava/lang/Integer; // TODO: need to skip kotlin signature
|
||||
// generic signature: null
|
||||
@@ -3,5 +3,4 @@ fun foo(p: List<CharSequence>) = 1
|
||||
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: (Ljava/util/List;)I
|
||||
// generic signature: (Ljava/util/List<+Ljava/lang/CharSequence;>;)I
|
||||
// kotlin signature: (Ljet/List<Ljava/lang/CharSequence;>;)I // TODO: skip Kotlin signature
|
||||
// generic signature: (Ljava/util/List<+Ljava/lang/CharSequence;>;)I
|
||||
@@ -3,5 +3,4 @@ fun listOfStar(): List<*> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::listOfStar
|
||||
// jvm signature: ()Ljava/util/List;
|
||||
// generic signature: ()Ljava/util/List<Ljava/lang/Object;>;
|
||||
// kotlin signature: ()Ljet/List<?Ljava/lang/Object;>;
|
||||
// generic signature: ()Ljava/util/List<Ljava/lang/Object;>;
|
||||
@@ -2,5 +2,4 @@ fun getEntry(): jet.Map.Entry<Int, String>? = null
|
||||
|
||||
// method: _DefaultPackage::getEntry
|
||||
// jvm signature: ()Ljava/util/Map$Entry;
|
||||
// generic signature: ()Ljava/util/Map$Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
// kotlin signature: ()?Ljet/Map.Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
// generic signature: ()Ljava/util/Map$Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
@@ -2,5 +2,4 @@ fun getEntry(): jet.MutableMap.MutableEntry<Int, String>? = null
|
||||
|
||||
// method: _DefaultPackage::getEntry
|
||||
// jvm signature: ()Ljava/util/Map$Entry;
|
||||
// generic signature: ()Ljava/util/Map$Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
// kotlin signature: ()?Ljet/MutableMap.MutableEntry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
// generic signature: ()Ljava/util/Map$Entry<Ljava/lang/Integer;Ljava/lang/String;>;
|
||||
@@ -2,5 +2,4 @@ fun foo() = 1
|
||||
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: ()I
|
||||
// generic signature: null
|
||||
// kotlin signature: ()I // TODO: need to skip kotlin signature
|
||||
// generic signature: null
|
||||
@@ -2,5 +2,4 @@ fun nothing(): Nothing = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::nothing
|
||||
// jvm signature: ()V
|
||||
// generic signature: null
|
||||
// kotlin signature: ()Ljet/Nothing;
|
||||
// generic signature: null
|
||||
@@ -2,5 +2,4 @@ fun nothingq(): Nothing? = null
|
||||
|
||||
// method: _DefaultPackage::nothingq
|
||||
// jvm signature: ()Ljava/lang/Object;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()?Ljet/Nothing;
|
||||
// generic signature: null
|
||||
@@ -2,5 +2,4 @@ fun foo(vararg tail: java.lang.CharSequence) = 1
|
||||
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: ([Ljava/lang/CharSequence;)I
|
||||
// generic signature: null
|
||||
// kotlin signature: ([Mjava/lang/CharSequence;)I // TODO: need to skip kotlin signature
|
||||
// generic signature: null
|
||||
@@ -2,7 +2,4 @@ fun <P> foo(vararg tail: P) = 1
|
||||
|
||||
// method: _DefaultPackage::foo
|
||||
// jvm signature: ([Ljava/lang/Object;)I
|
||||
// generic signature: <P:Ljava/lang/Object;>([TP;)I
|
||||
// kotlin signature: <erased P:?Ljava/lang/Object;>([TP;)I
|
||||
// TODO: skip kotlin signature
|
||||
// TODO: properly serialize typeinfo
|
||||
// generic signature: <P:Ljava/lang/Object;>([TP;)I
|
||||
@@ -3,4 +3,3 @@ class Constructor0()
|
||||
// method: Constructor0::<init>
|
||||
// jvm signature: ()V
|
||||
// generic signature: null
|
||||
// kotlin signature: null
|
||||
|
||||
@@ -4,4 +4,3 @@ class TestingKotlinCollections(val arguments: Collection<String>)
|
||||
// method: TestingKotlinCollections::<init>
|
||||
// jvm signature: (Ljava/util/Collection;)V
|
||||
// generic signature: (Ljava/util/Collection<+Ljava/lang/String;>;)V
|
||||
// kotlin signature: (Ljet/Collection<Ljava/lang/String;>;)null
|
||||
|
||||
@@ -3,4 +3,3 @@ class ConstructorWithTypeParameter<P>()
|
||||
// method: ConstructorWithTypeParameter::<init>
|
||||
// jvm signature: ()V
|
||||
// generic signature: null
|
||||
// kotlin signature: null
|
||||
|
||||
-1
@@ -3,4 +3,3 @@ class ConstructorWithTypeParameter<P>(p: P)
|
||||
// method: ConstructorWithTypeParameter::<init>
|
||||
// jvm signature: (Ljava/lang/Object;)V
|
||||
// generic signature: (TP;)V
|
||||
// kotlin signature: (TP;)null
|
||||
|
||||
+1
-2
@@ -6,5 +6,4 @@ fun f(m: M<X, X>): M<X, X> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LM;)LM;
|
||||
// generic signature: (LM<-LX;+LX;>;)LM<LX;LX;>;
|
||||
// kotlin signature: (LM<LX;LX;>;)LM<LX;LX;>;
|
||||
// generic signature: (LM<-LX;+LX;>;)LM<LX;LX;>;
|
||||
@@ -4,5 +4,4 @@ fun f(p: In<String>) {}
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LIn;)V
|
||||
// generic signature: (LIn<-Ljava/lang/String;>;)V
|
||||
// kotlin signature: (LIn<Ljava/lang/String;>;)V
|
||||
// generic signature: (LIn<-Ljava/lang/String;>;)V
|
||||
@@ -4,5 +4,4 @@ fun f(): In<String> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LIn;
|
||||
// generic signature: ()LIn<Ljava/lang/String;>;
|
||||
// kotlin signature: ()LIn<Ljava/lang/String;>;
|
||||
// generic signature: ()LIn<Ljava/lang/String;>;
|
||||
@@ -5,5 +5,4 @@ fun f(p: In<In<X>>) {}
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LIn;)V
|
||||
// generic signature: (LIn<-LIn<-LX;>;>;)V
|
||||
// kotlin signature: (LIn<LIn<LX;>;>;)V
|
||||
// generic signature: (LIn<-LIn<-LX;>;>;)V
|
||||
@@ -5,5 +5,4 @@ fun f(): In<In<X>> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LIn;
|
||||
// generic signature: ()LIn<LIn<-LX;>;>;
|
||||
// kotlin signature: ()LIn<LIn<LX;>;>;
|
||||
// generic signature: ()LIn<LIn<-LX;>;>;
|
||||
@@ -6,5 +6,4 @@ fun f(p: In<Out<X>>) {}
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LIn;)V
|
||||
// generic signature: (LIn<-LOut<+LX;>;>;)V
|
||||
// kotlin signature: (LIn<LOut<LX;>;>;)V
|
||||
// generic signature: (LIn<-LOut<+LX;>;>;)V
|
||||
@@ -6,5 +6,4 @@ fun f(): In<Out<X>> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LIn;
|
||||
// generic signature: ()LIn<LOut<+LX;>;>;
|
||||
// kotlin signature: ()LIn<LOut<LX;>;>;
|
||||
// generic signature: ()LIn<LOut<+LX;>;>;
|
||||
@@ -2,5 +2,4 @@ fun f(p: List<String>) {}
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (Ljava/util/List;)V
|
||||
// generic signature: (Ljava/util/List<+Ljava/lang/String;>;)V
|
||||
// kotlin signature: (Ljet/List<Ljava/lang/String;>;)V
|
||||
// generic signature: (Ljava/util/List<+Ljava/lang/String;>;)V
|
||||
@@ -2,5 +2,4 @@ fun f(): List<String> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()Ljava/util/List;
|
||||
// generic signature: ()Ljava/util/List<Ljava/lang/String;>;
|
||||
// kotlin signature: ()Ljet/List<Ljava/lang/String;>;
|
||||
// generic signature: ()Ljava/util/List<Ljava/lang/String;>;
|
||||
@@ -6,5 +6,4 @@ fun f(p: Out<In<X>>) {}
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LOut;)V
|
||||
// generic signature: (LOut<+LIn<-LX;>;>;)V
|
||||
// kotlin signature: (LOut<LIn<LX;>;>;)V
|
||||
// generic signature: (LOut<+LIn<-LX;>;>;)V
|
||||
@@ -6,5 +6,4 @@ fun f(): Out<In<X>> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LOut;
|
||||
// generic signature: ()LOut<LIn<-LX;>;>;
|
||||
// kotlin signature: ()LOut<LIn<LX;>;>;
|
||||
// generic signature: ()LOut<LIn<-LX;>;>;
|
||||
@@ -5,5 +5,4 @@ fun f(p: Out<Out<X>>) {}
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: (LOut;)V
|
||||
// generic signature: (LOut<+LOut<+LX;>;>;)V
|
||||
// kotlin signature: (LOut<LOut<LX;>;>;)V
|
||||
// generic signature: (LOut<+LOut<+LX;>;>;)V
|
||||
@@ -15,5 +15,4 @@ fun f(): Out<Out<X>> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::f
|
||||
// jvm signature: ()LOut;
|
||||
// generic signature: ()LOut<LOut<+LX;>;>;
|
||||
// kotlin signature: ()LOut<LOut<LX;>;>;
|
||||
// generic signature: ()LOut<LOut<+LX;>;>;
|
||||
@@ -5,5 +5,4 @@ val p: M<X> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::getP
|
||||
// jvm signature: ()LM;
|
||||
// generic signature: ()LM<LX;>;
|
||||
// kotlin signature: null
|
||||
// generic signature: ()LM<LX;>;
|
||||
@@ -5,5 +5,4 @@ val p: M<X> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::getP
|
||||
// jvm signature: ()LM;
|
||||
// generic signature: ()LM<LX;>;
|
||||
// kotlin signature: null
|
||||
// generic signature: ()LM<LX;>;
|
||||
@@ -5,5 +5,4 @@ val p: M<X, X> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::getP
|
||||
// jvm signature: ()LM;
|
||||
// generic signature: ()LM<LX;LX;>;
|
||||
// kotlin signature: null
|
||||
// generic signature: ()LM<LX;LX;>;
|
||||
@@ -5,5 +5,4 @@ var p: M<X> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::setP
|
||||
// jvm signature: (LM;)V
|
||||
// generic signature: (LM<-LX;>;)V
|
||||
// kotlin signature: (LM<LX;>;)null
|
||||
// generic signature: (LM<-LX;>;)V
|
||||
@@ -5,5 +5,4 @@ var p: M<X> = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::setP
|
||||
// jvm signature: (LM;)V
|
||||
// generic signature: (LM<+LX;>;)V
|
||||
// kotlin signature: (LM<LX;>;)null
|
||||
// generic signature: (LM<+LX;>;)V
|
||||
@@ -2,5 +2,4 @@ fun string(): java.lang.String = throw Exception()
|
||||
|
||||
// method: _DefaultPackage::string
|
||||
// jvm signature: ()Ljava/lang/String;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()Mjava/lang/String;
|
||||
// generic signature: null
|
||||
@@ -24,7 +24,6 @@ import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.*;
|
||||
import org.jetbrains.asm4.commons.Method;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
|
||||
@@ -32,7 +31,6 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||
import org.jetbrains.jet.codegen.GenerationUtils;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
import org.junit.Assert;
|
||||
|
||||
@@ -51,8 +49,6 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class WriteSignatureTest extends TestCaseWithTmpdir {
|
||||
|
||||
private static final AnnotationVisitor EMPTY_ANNOTATION_VISITOR = new AnnotationVisitor(Opcodes.ASM4) {};
|
||||
|
||||
private final File ktFile;
|
||||
private JetCoreEnvironment jetCoreEnvironment;
|
||||
|
||||
@@ -96,27 +92,24 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
||||
String template =
|
||||
"jvm signature: %s\n" +
|
||||
"generic signature: %s\n" +
|
||||
"kotlin signature: %s\n" +
|
||||
"";
|
||||
|
||||
String expected = String.format(template, expectation.jvmSignature, expectation.genericSignature, expectation.kotlinSignature);
|
||||
String actual = String.format(template, actualSignature.jvmSignature, actualSignature.genericSignature, actualSignature.kotlinSignature);
|
||||
String expected = String.format(template, expectation.jvmSignature, expectation.genericSignature);
|
||||
String actual = String.format(template, actualSignature.jvmSignature, actualSignature.genericSignature);
|
||||
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
||||
private static class ActualSignature {
|
||||
private final String jvmSignature;
|
||||
private final String genericSignature;
|
||||
private final String kotlinSignature;
|
||||
|
||||
private ActualSignature(@NotNull String jvmSignature, @Nullable String genericSignature, @Nullable String kotlinSignature) {
|
||||
private ActualSignature(@NotNull String jvmSignature, @Nullable String genericSignature) {
|
||||
this.jvmSignature = jvmSignature;
|
||||
this.genericSignature = genericSignature;
|
||||
this.kotlinSignature = kotlinSignature;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private ActualSignature readSignature(String className, final String methodName) throws Exception {
|
||||
// ugly unreadable code begin
|
||||
@@ -133,143 +126,47 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
||||
public MethodVisitor visitMethod(int access, String name, final String desc, final String signature, String[] exceptions) {
|
||||
if (name.equals(methodName)) {
|
||||
|
||||
final int parameterCount = new Method(name, desc).getArgumentTypes().length;
|
||||
|
||||
return new MethodVisitor(Opcodes.ASM4) {
|
||||
String typeParameters = "";
|
||||
String returnType;
|
||||
String[] parameterTypes = new String[parameterCount];
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
if (desc.equals(JvmStdlibNames.JET_METHOD.getDescriptor())) {
|
||||
return new AnnotationVisitor(Opcodes.ASM4) {
|
||||
@Override
|
||||
public void visit(String name, Object value) {
|
||||
if (name.equals(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD)) {
|
||||
typeParameters = (String) value;
|
||||
}
|
||||
else if (name.equals(JvmStdlibNames.JET_METHOD_RETURN_TYPE_FIELD)) {
|
||||
returnType = (String) value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String s, String s1) {
|
||||
return EMPTY_ANNOTATION_VISITOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitArray(String name) {
|
||||
return EMPTY_ANNOTATION_VISITOR;
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
return EMPTY_ANNOTATION_VISITOR;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitParameterAnnotation(final int parameter, String desc, boolean visible) {
|
||||
if (desc.equals(JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor())) {
|
||||
return new AnnotationVisitor(Opcodes.ASM4) {
|
||||
@Override
|
||||
public void visit(String name, Object value) {
|
||||
if (name.equals(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD)) {
|
||||
parameterTypes[parameter] = (String) value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String name, String desc) {
|
||||
return EMPTY_ANNOTATION_VISITOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitArray(String name) {
|
||||
return EMPTY_ANNOTATION_VISITOR;
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
return EMPTY_ANNOTATION_VISITOR;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotationDefault() {
|
||||
return EMPTY_ANNOTATION_VISITOR;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String makeKotlinSignature() {
|
||||
boolean allNulls = true;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(typeParameters);
|
||||
if (typeParameters != null && typeParameters.length() > 0) {
|
||||
allNulls = false;
|
||||
}
|
||||
sb.append("(");
|
||||
for (String parameterType : parameterTypes) {
|
||||
sb.append(parameterType);
|
||||
if (parameterType != null) {
|
||||
allNulls = false;
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
sb.append(returnType);
|
||||
if (returnType != null) {
|
||||
allNulls = false;
|
||||
}
|
||||
if (allNulls) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnd() {
|
||||
Assert.assertNull(readSignature);
|
||||
readSignature = new ActualSignature(desc, signature, makeKotlinSignature());
|
||||
readSignature = new ActualSignature(desc, signature);
|
||||
}
|
||||
};
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Visitor visitor = new Visitor();
|
||||
|
||||
|
||||
new ClassReader(classInputStream).accept(visitor,
|
||||
ClassReader.SKIP_CODE|ClassReader.SKIP_DEBUG|ClassReader.SKIP_FRAMES);
|
||||
|
||||
ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||
|
||||
Assert.assertNotNull("method not found: " + className + "::" + methodName, visitor.readSignature);
|
||||
|
||||
return visitor.readSignature;
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
Closeables.closeQuietly(classInputStream);
|
||||
}
|
||||
// ugly unreadable code end
|
||||
}
|
||||
|
||||
|
||||
private static class Expectation {
|
||||
private final String className;
|
||||
private final String methodName;
|
||||
private final String jvmSignature;
|
||||
private final String genericSignature;
|
||||
private final String kotlinSignature;
|
||||
|
||||
private Expectation(@NotNull String className, @NotNull String methodName,
|
||||
@NotNull String jvmSignature, @Nullable String genericSignature, @Nullable String kotlinSignature) {
|
||||
private Expectation(
|
||||
@NotNull String className, @NotNull String methodName,
|
||||
@NotNull String jvmSignature, @Nullable String genericSignature
|
||||
) {
|
||||
this.className = className;
|
||||
this.methodName = methodName;
|
||||
this.jvmSignature = jvmSignature;
|
||||
this.genericSignature = genericSignature;
|
||||
this.kotlinSignature = kotlinSignature;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,46 +174,44 @@ public class WriteSignatureTest extends TestCaseWithTmpdir {
|
||||
private static final Pattern methodPattern = Pattern.compile("^// method: *(.*)::(.*?) *(//.*)?");
|
||||
private static final Pattern jvmSignaturePattern = Pattern.compile("^// jvm signature: *(.+?) *(//.*)?");
|
||||
private static final Pattern genericSignaturePattern = Pattern.compile("^// generic signature: *(.+?) *(//.*)?");
|
||||
private static final Pattern kotlinSignaturePattern = Pattern.compile("^// kotlin signature: *(.+?) *(//.*)?");
|
||||
|
||||
private Expectation parseExpectations() throws IOException {
|
||||
List<String> lines = Files.readLines(ktFile, Charset.forName("utf-8"));
|
||||
for (int i = 0; i < lines.size() - 3; ++i) {
|
||||
for (int i = 0; i < lines.size() - 2; ++i) {
|
||||
Matcher methodMatcher = methodPattern.matcher(lines.get(i));
|
||||
if (methodMatcher.matches()) {
|
||||
Matcher jvmSignatureMatcher = jvmSignaturePattern.matcher(lines.get(i + 1));
|
||||
Matcher genericSignatureMatcher = genericSignaturePattern.matcher(lines.get(i + 2));
|
||||
Matcher kotlinSignatureMatcher = kotlinSignaturePattern.matcher(lines.get(i + 3));
|
||||
if (!jvmSignatureMatcher.matches() || !genericSignatureMatcher.matches() || !kotlinSignatureMatcher.matches()) {
|
||||
if (!jvmSignatureMatcher.matches() || !genericSignatureMatcher.matches()) {
|
||||
throw new AssertionError("'method:' must be followed ... bla bla ... use the source luke");
|
||||
}
|
||||
|
||||
|
||||
String className = methodMatcher.group(1);
|
||||
String methodName = methodMatcher.group(2);
|
||||
|
||||
|
||||
String jvmSignature = jvmSignatureMatcher.group(1);
|
||||
String genericSignature = genericSignatureMatcher.group(1);
|
||||
String kotlinSignature = kotlinSignatureMatcher.group(1);
|
||||
if (genericSignature.equals("null")) {
|
||||
genericSignature = null;
|
||||
}
|
||||
if (kotlinSignature.equals("null")) {
|
||||
kotlinSignature = null;
|
||||
}
|
||||
return new Expectation(className, methodName, jvmSignature, genericSignature, kotlinSignature);
|
||||
return new Expectation(className, methodName, jvmSignature, genericSignature);
|
||||
}
|
||||
}
|
||||
throw new AssertionError("test instructions not found in " + ktFile);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/writeSignature", true, new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name, @NotNull File file) {
|
||||
return new WriteSignatureTest(file);
|
||||
}
|
||||
});
|
||||
|
||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/writeSignature", true,
|
||||
new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(
|
||||
@NotNull String dataPath,
|
||||
@NotNull String name,
|
||||
@NotNull File file
|
||||
) {
|
||||
return new WriteSignatureTest(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user