Files
openide/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/codeInspection/tests/kotlin/RedundantRequiresStatementTest.kt
Bart van Helvert d5e57a6595 [jvm] Clean up tests
GitOrigin-RevId: 28d58f839acd78a42345885b7246073e8e7ac800
2022-07-15 10:22:14 +00:00

39 lines
1.9 KiB
Kotlin

// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInspection.tests.kotlin
import com.intellij.analysis.AnalysisScope
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper
import com.intellij.codeInspection.java19modules.Java9RedundantRequiresStatementInspection
import com.intellij.java.testFramework.fixtures.LightJava9ModulesCodeInsightFixtureTestCase
import com.intellij.java.testFramework.fixtures.MultiModuleJava9ProjectDescriptor
import com.intellij.jvm.analysis.KotlinJvmAnalysisTestUtil
import com.intellij.openapi.application.PathManager
import com.intellij.testFramework.InspectionTestUtil
import com.intellij.testFramework.createGlobalContextForTool
import java.io.File
class RedundantRequiresStatementTest : LightJava9ModulesCodeInsightFixtureTestCase() {
fun testStdlib() {
val mainText = """
package org.example.main
class Main {
fun main() {}
}""".trimIndent()
addFile("org.example.main/Main.kt", mainText)
addFile("module-info.java", "module MAIN { requires kotlin.stdlib; }", MultiModuleJava9ProjectDescriptor.ModuleDescriptor.MAIN)
val toolWrapper = GlobalInspectionToolWrapper(Java9RedundantRequiresStatementInspection())
val scope = AnalysisScope(project)
val globalContext = createGlobalContextForTool(scope, project, listOf(toolWrapper))
InspectionTestUtil.runTool(toolWrapper, scope, globalContext)
InspectionTestUtil.compareToolResults(globalContext, toolWrapper, true, testDataPath + getTestName(true))
}
override fun getBasePath(): String {
return KotlinJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH + "/codeInspection/redundantRequires/"
}
override fun getTestDataPath(): String {
return PathManager.getCommunityHomePath().replace(File.separatorChar, '/') + basePath
}
}