From 9df3c220975c397e625ad307fe17d8ac3d5261e2 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 7 Feb 2013 22:40:25 +0400 Subject: [PATCH] Kill blackBoxFile() If your test is supposed to use blackBoxFile(), maybe it should be placed into box/boxWithStdlib directory --- .../notNullAssertions/doGenerateParamAssertions.java | 6 +++--- .../notNullAssertions/doGenerateParamAssertions.kt | 2 +- .../org/jetbrains/jet/codegen/CodegenTestCase.java | 6 +----- .../org/jetbrains/jet/codegen/ComponentGenTest.java | 11 +++-------- .../jet/codegen/GenerateNotNullAssertionsTest.java | 3 ++- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.java b/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.java index 34289912f4e..deda44cb68f 100644 --- a/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.java +++ b/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.java @@ -6,12 +6,12 @@ public abstract class doGenerateParamAssertions { public abstract void bar(@NotNull String s); - public static String foo(doGenerateParamAssertions a) { + public static void foo(doGenerateParamAssertions a) { try { a.bar(null); } catch (IllegalArgumentException e) { - return "OK"; + return; } - return "Fail: AssertionError expected"; + throw new AssertionError("Fail: IllegalArgumentException expected"); } } diff --git a/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.kt b/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.kt index 0e352285f21..f887a801ddb 100644 --- a/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.kt +++ b/compiler/testData/codegen/notNullAssertions/doGenerateParamAssertions.kt @@ -5,4 +5,4 @@ class A : C() { } } -fun box() = C.foo(A()) +fun doTest() = C.foo(A()) diff --git a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java index 31c9288ab9f..f038ba6eaf2 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java +++ b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java @@ -105,10 +105,6 @@ public abstract class CodegenTestCase extends UsefulTestCase { throw new UnsupportedOperationException(); } - protected void blackBoxFile(@NotNull String filename) { - blackBoxMultiFile(filename); - } - protected void blackBoxFileByFullPath(@NotNull String filename) { loadFileByFullPath(filename); blackBox(); @@ -148,7 +144,7 @@ public abstract class CodegenTestCase extends UsefulTestCase { myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests( ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, JetTestUtils.getAnnotationsJar(), javaClassesTempDirectory)); - blackBoxFile(ktFile); + blackBoxMultiFile(ktFile); } @NotNull diff --git a/compiler/tests/org/jetbrains/jet/codegen/ComponentGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ComponentGenTest.java index 804b5fc2d3e..31e87a480d7 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ComponentGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ComponentGenTest.java @@ -16,6 +16,7 @@ package org.jetbrains.jet.codegen; +import org.apache.commons.lang.StringUtils; import org.jetbrains.jet.ConfigurationKind; /** @@ -25,13 +26,7 @@ import org.jetbrains.jet.ConfigurationKind; public class ComponentGenTest extends CodegenTestCase { public void testComponent() { createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); - blackBoxFile("componentEvaluatesOnlyOnce.kt"); - - String asm = generateToText(); - //System.out.println(asm); - final String pattern = "NEW S\n"; - final int index = asm.indexOf(pattern); - asm = asm.substring(index + pattern.length()); - assertEquals(-1, asm.indexOf(pattern)); + loadFile("componentEvaluatesOnlyOnce.kt"); + assertEquals(1, StringUtils.countMatches(generateToText(), "NEW S\n")); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/GenerateNotNullAssertionsTest.java b/compiler/tests/org/jetbrains/jet/codegen/GenerateNotNullAssertionsTest.java index 9d3c0ec3745..b45492e6947 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/GenerateNotNullAssertionsTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/GenerateNotNullAssertionsTest.java @@ -100,7 +100,8 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase { setUpEnvironment(false, true, javaClassesTempDirectory); - blackBoxFile("notNullAssertions/doGenerateParamAssertions.kt"); + loadFile("notNullAssertions/doGenerateParamAssertions.kt"); + generateFunction().invoke(null); } public void testDoNotGenerateParamAssertions() throws Exception {