Moved remaining case in LoadJavaCustomTest to generated one.

Supported multi-file cases.
This commit is contained in:
Evgeny Gerashchenko
2013-03-11 17:42:59 +04:00
parent 88cc767f77
commit 7f583cc798
6 changed files with 38 additions and 58 deletions
@@ -1,3 +1,13 @@
// FILE: Frame.java
package awt;
public class Frame {
String accessibleContext = null;
}
// FILE: JFrame.java
package test;
import awt.Frame;
@@ -1,7 +0,0 @@
package awt;
public class Frame {
String accessibleContext = null;
}
@@ -20,8 +20,6 @@ import com.google.common.base.Predicates;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.PsiFile;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import junit.framework.ComparisonFailure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.ConfigurationKind;
@@ -47,6 +45,7 @@ import org.junit.Assert;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -71,24 +70,34 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
}
protected void doTestCompiledJava(@NotNull String javaFileName) throws Exception {
doTestCompiledJava(new File(javaFileName.replaceFirst("\\.java$", ".txt")), javaFileName);
}
final File srcDir = new File(tmpdir, "src");
File compiledDir = new File(tmpdir, "compiled");
assertTrue(srcDir.mkdir());
assertTrue(compiledDir.mkdir());
List<File> srcFiles = JetTestUtils.createTestFiles(
new File(javaFileName).getName(), FileUtil.loadFile(new File(javaFileName)),
new JetTestUtils.TestFileFactory<File>() {
@Override
public File create(String fileName, String text) {
File targetFile = new File(srcDir, fileName);
try {
FileUtil.writeToFile(targetFile, text);
}
catch (IOException e) {
throw new AssertionError(e);
}
return targetFile;
}
});
protected void doTestCompiledJava(@NotNull File expectedFile, @NotNull String... javaFileNames) throws Exception {
JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
getTestRootDisposable(), ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK);
List<File> files = ContainerUtil.map(Arrays.asList(javaFileNames), new Function<String, File>() {
@Override
public File fun(String s) {
return new File(s);
}
});
Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext = compileJavaAndLoadTestNamespaceAndBindingContextFromBinary(
files, tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
srcFiles, compiledDir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second);
checkJavaNamespace(new File(javaFileName.replaceFirst("\\.java$", ".txt")), javaNamespaceAndContext.first, javaNamespaceAndContext.second);
}
protected void doTestSourceJava(@NotNull String javaFileName) throws Exception {
@@ -1,37 +0,0 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.jvm.compiler;
import org.jetbrains.annotations.NotNull;
import java.io.File;
/*
LoadJavaTestGenerated should be used instead if possible.
*/
public final class LoadJavaCustomTest extends AbstractLoadJavaTest {
@NotNull
private static final String PATH = "compiler/testData/loadJavaCustom";
public void testPackageLocalVisibility() throws Exception {
String dir = PATH + "/packageLocalVisibility/simple/";
String javaDir = dir + "/java";
doTestCompiledJava(new File(dir + "/expected.txt"),
javaDir + "/test/JFrame.java",
javaDir + "/awt/Frame.java");
}
}
@@ -982,6 +982,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/JavaEnum.java");
}
@TestMetadata("PackageLocalVisibility.java")
public void testPackageLocalVisibility() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/PackageLocalVisibility.java");
}
@TestMetadata("SubclassFromNested.java")
public void testSubclassFromNested() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/SubclassFromNested.java");