Sort out blackBox*() methods
- get rid of blackBox(), extract tests into files - delete single-file usages of blackBoxMultiFile() - inline some other blackBox methods - suppress exception in blackBoxWithJava()
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
class A() {
|
||||
class object {
|
||||
val value = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if (A.value == 10) "OK" else "Fail ${A.value}"
|
||||
@@ -0,0 +1,12 @@
|
||||
fun f(x: Long, zzz: Long = 1): Long
|
||||
{
|
||||
return if (x <= 1) zzz
|
||||
else f(x-1, x*zzz)
|
||||
}
|
||||
|
||||
fun box() : String
|
||||
{
|
||||
val six: Long = 6;
|
||||
if (f(six) != 720.toLong()) return "Fail"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
fun box() = if ((1 ?: 0) == 1) "OK" else "fail"
|
||||
@@ -0,0 +1,5 @@
|
||||
fun box(): String {
|
||||
if (3.compareTo(2) != 1) return "Fail #1"
|
||||
if (5.toByte().compareTo(10.toLong()) >= 0) return "Fail #2"
|
||||
return "OK"
|
||||
}
|
||||
@@ -248,9 +248,7 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testClassObjFields() {
|
||||
loadText("class A() { class object { val value = 10 } }\n" +
|
||||
"fun box() = if(A.value == 10) \"OK\" else \"fail\"");
|
||||
blackBox();
|
||||
blackBoxFile("classes/classObjectField.kt");
|
||||
}
|
||||
|
||||
public void testPrivateOuterProperty() {
|
||||
@@ -434,15 +432,15 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testKt2395() {
|
||||
blackBoxMultiFile("regressions/kt2395.kt");
|
||||
blackBoxFile("regressions/kt2395.kt");
|
||||
}
|
||||
|
||||
public void testKt2566() {
|
||||
blackBoxMultiFile("regressions/kt2566.kt");
|
||||
blackBoxFile("regressions/kt2566.kt");
|
||||
}
|
||||
|
||||
public void testKt2566_2() {
|
||||
blackBoxMultiFile("regressions/kt2566_2.kt");
|
||||
blackBoxFile("regressions/kt2566_2.kt");
|
||||
}
|
||||
|
||||
public void testKt2477() {
|
||||
@@ -450,11 +448,11 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testKt2485() {
|
||||
blackBoxMultiFile("regressions/kt2485.kt");
|
||||
blackBoxFile("regressions/kt2485.kt");
|
||||
}
|
||||
|
||||
public void testKt2482() {
|
||||
blackBoxMultiFile("regressions/kt2482.kt");
|
||||
blackBoxFile("regressions/kt2482.kt");
|
||||
}
|
||||
|
||||
public void testKt2288() {
|
||||
|
||||
@@ -158,24 +158,19 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
blackBoxFile(filename, false);
|
||||
}
|
||||
|
||||
protected void blackBoxFile(String filename, boolean classPathInTheSameClassLoader) {
|
||||
private void blackBoxFile(String filename, boolean classPathInTheSameClassLoader) {
|
||||
loadFile(filename);
|
||||
blackBox(classPathInTheSameClassLoader);
|
||||
}
|
||||
|
||||
protected void blackBoxFileByFullPath(String filename) {
|
||||
loadFileByFullPath(filename);
|
||||
blackBox();
|
||||
blackBox(false);
|
||||
}
|
||||
|
||||
protected void blackBoxMultiFile(String... filenames) {
|
||||
loadFiles(filenames);
|
||||
blackBox();
|
||||
}
|
||||
|
||||
protected void blackBoxMultiFile(boolean classPathInTheSameClassLoader, String... filenames) {
|
||||
loadFiles(filenames);
|
||||
blackBox(classPathInTheSameClassLoader);
|
||||
blackBox(false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -217,11 +212,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void blackBox() {
|
||||
blackBox(false);
|
||||
}
|
||||
|
||||
protected void blackBox(boolean classPathInTheSameClassLoader) {
|
||||
private void blackBox(boolean classPathInTheSameClassLoader) {
|
||||
GenerationState state = generateClassesInFileGetState();
|
||||
|
||||
GeneratedClassLoader loader = createClassLoader(state.getFactory(), classPathInTheSameClassLoader);
|
||||
@@ -280,15 +271,15 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void blackBoxFileWithJavaByFullPath(@NotNull String ktFile) throws Exception {
|
||||
protected void blackBoxFileWithJavaByFullPath(@NotNull String ktFile) {
|
||||
blackBoxFileWithJava(ktFile.substring("compiler/testData/codegen/".length()), false);
|
||||
}
|
||||
|
||||
protected void blackBoxFileWithJava(@NotNull String ktFile) throws Exception {
|
||||
protected void blackBoxFileWithJava(@NotNull String ktFile) {
|
||||
blackBoxFileWithJava(ktFile, false);
|
||||
}
|
||||
|
||||
protected void blackBoxFileWithJava(@NotNull String ktFile, boolean classPathInTheSameClassLoader) throws Exception {
|
||||
protected void blackBoxFileWithJava(@NotNull String ktFile, boolean classPathInTheSameClassLoader) {
|
||||
File javaClassesTempDirectory = compileJava(ktFile.replaceFirst("\\.kt$", ".java"));
|
||||
|
||||
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests(
|
||||
@@ -297,19 +288,24 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
blackBoxFile(ktFile, classPathInTheSameClassLoader);
|
||||
}
|
||||
|
||||
protected File compileJava(@NotNull String filename) throws IOException {
|
||||
File javaClassesTempDirectory = new File(FileUtil.getTempDirectory(), "java-classes");
|
||||
JetTestUtils.mkdirs(javaClassesTempDirectory);
|
||||
String classPath = "out/production/runtime" + File.pathSeparator + JetTestUtils.getAnnotationsJar().getPath();
|
||||
List<String> options = Arrays.asList(
|
||||
"-classpath", classPath,
|
||||
"-d", javaClassesTempDirectory.getPath()
|
||||
);
|
||||
protected File compileJava(@NotNull String filename) {
|
||||
try {
|
||||
File javaClassesTempDirectory = new File(FileUtil.getTempDirectory(), "java-classes");
|
||||
JetTestUtils.mkdirs(javaClassesTempDirectory);
|
||||
String classPath = "out/production/runtime" + File.pathSeparator + JetTestUtils.getAnnotationsJar().getPath();
|
||||
List<String> options = Arrays.asList(
|
||||
"-classpath", classPath,
|
||||
"-d", javaClassesTempDirectory.getPath()
|
||||
);
|
||||
|
||||
File javaFile = new File("compiler/testData/codegen/" + filename);
|
||||
JetTestUtils.compileJavaFiles(Collections.singleton(javaFile), options);
|
||||
File javaFile = new File("compiler/testData/codegen/" + filename);
|
||||
JetTestUtils.compileJavaFiles(Collections.singleton(javaFile), options);
|
||||
|
||||
return javaClassesTempDirectory;
|
||||
return javaClassesTempDirectory;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected GeneratedClassLoader createClassLoader(ClassFileFactory codegens) {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
||||
|
||||
setUpEnvironment(generateAssertions, false, javaClassesTempDirectory);
|
||||
|
||||
blackBoxMultiFile(false, "notNullAssertions/AssertionChecker.kt", ktFile);
|
||||
blackBoxMultiFile("notNullAssertions/AssertionChecker.kt", ktFile);
|
||||
}
|
||||
|
||||
public void testGenerateAssertions() throws Exception {
|
||||
|
||||
@@ -300,9 +300,8 @@ public class PrimitiveTypesTest extends CodegenTestCase {
|
||||
blackBoxFile("regressions/kt518.kt");
|
||||
}
|
||||
|
||||
public void testKt711 () throws Exception {
|
||||
loadText("fun box() = if ((1 ?: 0) == 1) \"OK\" else \"fail\"");
|
||||
blackBox();
|
||||
public void testKt711() {
|
||||
blackBoxFile("primitiveTypes/kt711.kt");
|
||||
}
|
||||
|
||||
public void testSureNonnull () throws Exception {
|
||||
@@ -325,25 +324,12 @@ public class PrimitiveTypesTest extends CodegenTestCase {
|
||||
assertTrue(generateToText().contains("IFNULL"));
|
||||
}
|
||||
|
||||
public void testKt737() throws Exception {
|
||||
loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.toByte().compareTo(10.toLong()) >= 0) \"fail\" else \"OK\"");
|
||||
blackBox();
|
||||
public void testKt737() {
|
||||
blackBoxFile("primitiveTypes/kt737.kt");
|
||||
}
|
||||
|
||||
public void testKt665() throws Exception {
|
||||
loadText("fun f(x: Long, zzz: Long = 1): Long\n" +
|
||||
"{\n" +
|
||||
" return if (x <= 1) zzz\n" +
|
||||
" else f(x-1, x*zzz)\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"fun box() : String\n" +
|
||||
"{\n" +
|
||||
" val six: Long = 6;\n" +
|
||||
" System.out?.println(f(six))\n" +
|
||||
" return \"OK\"" +
|
||||
"}");
|
||||
blackBox();
|
||||
public void testKt665() {
|
||||
blackBoxFile("primitiveTypes/kt665.kt");
|
||||
}
|
||||
|
||||
public void testKt752 () {
|
||||
|
||||
@@ -93,10 +93,8 @@ public class StdlibTest extends CodegenTestCase {
|
||||
blackBoxFile("regressions/kt274.kt");
|
||||
}
|
||||
|
||||
//from ClassGenTest
|
||||
public void testKt344 () throws Exception {
|
||||
loadFile("regressions/kt344.kt");
|
||||
blackBox();
|
||||
public void testKt344 () {
|
||||
blackBoxFile("regressions/kt344.kt");
|
||||
}
|
||||
|
||||
//from ExtensionFunctionsTest
|
||||
|
||||
Reference in New Issue
Block a user