diff --git a/idea/tests/org/jetbrains/jet/plugin/compilerMessages/IDECompilerMessagingTest.java b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/IDECompilerMessagingTest.java index 16c50110b4c59464dffa4d8dbd8e6009ee86f84c..12bcf7defd83aa21f4a5ad9146ec3354c9be8c26 100644 --- a/idea/tests/org/jetbrains/jet/plugin/compilerMessages/IDECompilerMessagingTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/IDECompilerMessagingTest.java @@ -16,6 +16,7 @@ package org.jetbrains.jet.plugin.compilerMessages; +import com.intellij.openapi.compiler.TranslatingCompiler; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.PlatformTestCase; @@ -32,44 +33,12 @@ import static org.jetbrains.jet.plugin.compilerMessages.Message.warning; /** * @author Pavel Talanov */ -public final class IDECompilerMessagingTest extends PlatformTestCase { +public abstract class IDECompilerMessagingTest extends PlatformTestCase { private static final String TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/compilerMessages"; - public void testHelloWorld() { - doTest(new Function1() { - @Override - public Void invoke(MessageChecker checker) { - //nothing apart from header - return null; - } - }); - } - - - public void testSimpleWarning() { - doTest(new Function1() { - @Override - public Void invoke(MessageChecker checker) { - checker.expect(warning().text("Unnecessary non-null assertion (!!) on a non-null receiver of type jet.String") - .at("test.kt", 4, 4)); - return null; - } - }); - } - - public void testSimpleError() { - doTest(new Function1() { - @Override - public Void invoke(MessageChecker checker) { - checker.expect( - error().text("A 'return' expression required in a function with a block body ('{...}')").at("test.kt", 5, 1)); - return null; - } - }); - } - private void doTest(@NotNull Function1 whatToExpect) { + protected void performTest(Function1 whatToExpect, @NotNull TranslatingCompiler compiler) { String pathToTestDir = TEST_DATA_PATH + "/" + getTestName(true); VirtualFile testDir = LocalFileSystem.getInstance().findFileByPath(pathToTestDir); VirtualFile sampleFile = LocalFileSystem.getInstance().findFileByPath(pathToTestDir + "/src/test.kt"); @@ -77,7 +46,7 @@ public final class IDECompilerMessagingTest extends PlatformTestCase { VirtualFile root = LocalFileSystem.getInstance().findFileByPath(pathToTestDir + "/src/"); MockCompileContext mockCompileContext = new MockCompileContext(myModule, outDirectory, root); MockModuleChunk mockModuleChunk = new MockModuleChunk(myModule); - new JetCompiler() + compiler .compile(mockCompileContext, mockModuleChunk, new VirtualFile[] {sampleFile}, new MockOutputSink()); MessageChecker checker = new MessageChecker(mockCompileContext); checkHeader(checker); diff --git a/idea/tests/org/jetbrains/jet/plugin/compilerMessages/JetCompilerMessagingTest.java b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/JetCompilerMessagingTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b73d19029160c8e48bd70dd92987e00c6cdac38b --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/compilerMessages/JetCompilerMessagingTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2012 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.plugin.compilerMessages; + +import jet.Function1; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.plugin.compiler.JetCompiler; + +import static org.jetbrains.jet.plugin.compilerMessages.Message.error; +import static org.jetbrains.jet.plugin.compilerMessages.Message.warning; + +/** + * @author Pavel Talanov + */ +public final class JetCompilerMessagingTest extends IDECompilerMessagingTest { + + + public void testHelloWorld() { + doTest(new Function1() { + @Override + public Void invoke(MessageChecker checker) { + //nothing apart from header + return null; + } + }); + } + + + public void testSimpleWarning() { + doTest(new Function1() { + @Override + public Void invoke(MessageChecker checker) { + checker.expect(warning().text("Unnecessary non-null assertion (!!) on a non-null receiver of type jet.String") + .at("test.kt", 4, 4)); + return null; + } + }); + } + + public void testSimpleError() { + doTest(new Function1() { + @Override + public Void invoke(MessageChecker checker) { + checker.expect( + error().text("A 'return' expression required in a function with a block body ('{...}')").at("test.kt", 5, 1)); + return null; + } + }); + } + + private void doTest(@NotNull Function1 whatToExpect) { + JetCompiler compiler = new JetCompiler(); + performTest(whatToExpect, compiler); + } +}