mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (test consolidation; code reuse)
This commit is contained in:
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon
|
||||
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.testFramework.LightPlatformTestCase
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.MultiModuleJava9ProjectDescriptor
|
||||
import com.intellij.testFramework.VfsTestUtil
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
|
||||
|
||||
@@ -33,29 +32,35 @@ class ModuleHighlightingTest : LightCodeInsightFixtureTestCase() {
|
||||
}
|
||||
|
||||
fun testFileDuplicate() {
|
||||
additionalFile("""module M.bis { }""")
|
||||
addFile("pkg/module-info.java", """module M.bis { }""")
|
||||
doTest("""<error descr="'module-info.java' already exists in the module">module M</error> { }""")
|
||||
}
|
||||
|
||||
fun testWrongFileLocation() {
|
||||
additionalFile("""<warning descr="Module declaration should be located in a module's source root">module M</warning> { }""")
|
||||
val file = addFile("pkg/module-info.java", """<warning descr="Module declaration should be located in a module's source root">module M</warning> { }""")
|
||||
myFixture.configureFromExistingVirtualFile(file)
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
|
||||
fun testDuplicateRequires() = doTest("""module M { requires M2; <error descr="Duplicate requires: M2">requires M2;</error> }""", true)
|
||||
fun testRequires() {
|
||||
doTest("""
|
||||
module M1 {
|
||||
requires <error descr="Module not found: M.missing">M.missing</error>;
|
||||
requires <error descr="Cyclic dependence: M1">M1</error>;
|
||||
requires <error descr="Cyclic dependence: M1, M2">M2</error>;
|
||||
}""".trimIndent(), true)
|
||||
}
|
||||
|
||||
fun testUnresolvedModule() = doTest("""module M { requires <error descr="Module not found: M.missing">M.missing</error>; }""")
|
||||
|
||||
fun testSelfDependence() = doTest("""module M { requires <error descr="Cyclic dependence: M">M</error>; }""")
|
||||
|
||||
fun testCyclicDependence() = doTest("""module M1 { requires <error descr="Cyclic dependence: M1, M2">M2</error>; }""", true)
|
||||
fun testDuplicateRequires() {
|
||||
doTest("""
|
||||
module M {
|
||||
requires M2;
|
||||
<error descr="Duplicate requires: M2">requires M2;</error>
|
||||
}""".trimIndent(), true)
|
||||
}
|
||||
|
||||
//<editor-fold desc="Helpers.">
|
||||
private fun additionalFile(text: String) = myFixture.configureFromExistingVirtualFile(runWriteAction {
|
||||
val file = LightPlatformTestCase.getSourceRoot().createChildDirectory(this, "pkg").createChildData(this, "module-info.java")
|
||||
VfsUtil.saveText(file, text)
|
||||
file
|
||||
})
|
||||
private fun addFile(path: String, text: String) = VfsTestUtil.createFile(LightPlatformTestCase.getSourceRoot(), path, text)
|
||||
|
||||
private fun doTest(text: String, filter: Boolean = false) {
|
||||
myFixture.configureByText("module-info.java", text)
|
||||
|
||||
Reference in New Issue
Block a user