Test that GenerateJavaToKotlinMethodMap has run correctly

This commit is contained in:
Andrey Breslav
2013-09-23 14:52:50 -07:00
parent 651cc26e5e
commit 587189433b
2 changed files with 22 additions and 3 deletions
@@ -57,7 +57,14 @@ public class GenerateJavaToKotlinMethodMap {
public static final String BUILTINS_FQNAME_PREFIX = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.asString() + ".";
public static final File TARGET_FILE =
new File("compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kotlinSignature/JavaToKotlinMethodMapGenerated.java");
public static void main(String[] args) throws IOException {
GeneratorsFileUtil.writeFileIfContentChanged(TARGET_FILE, generateText().toString());
}
public static CharSequence generateText() throws IOException {
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.add(CLASSPATH_KEY, PathUtil.findRtJar());
@@ -89,9 +96,7 @@ public class GenerateJavaToKotlinMethodMap {
printer.println("map = b.build();");
printer.popIndent().println("}");
printer.popIndent().println("}");
File file = new File("compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kotlinSignature/JavaToKotlinMethodMapGenerated.java");
GeneratorsFileUtil.writeFileIfContentChanged(file, buf.toString());
return buf;
}
private static class MyMapBuilder extends JavaToKotlinClassMapBuilder {
@@ -0,0 +1,14 @@
package org.jetbrains.jet.generators.jvm;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import junit.framework.Assert;
import junit.framework.TestCase;
public class GenerateJavaToKotlinMethodMapTest extends TestCase {
public void testGenerateJavaToKotlinMethodMap() throws Exception {
String text = StringUtil.convertLineSeparators(GenerateJavaToKotlinMethodMap.generateText().toString());
String expected = FileUtil.loadFile(GenerateJavaToKotlinMethodMap.TARGET_FILE, true);
Assert.assertEquals("To fix this problem you need to run GenerateJavaToKotlinMethodMap", expected, text);
}
}