Files
openide/jvm/jvm-analysis-kotlin-tests-shared/testSrc/com/intellij/codeInspection/tests/kotlin/KotlinSystemGetPropertyInspectionTest.kt
Bart van Helvert c8c478bdbc [jvm] Properly enable K2 mode for K2 tests
Also ignores any failing tests

GitOrigin-RevId: db34ca3d4690285cd7ed4186c76f31e81e7fab46
2024-09-12 10:09:27 +00:00

77 lines
2.7 KiB
Kotlin

package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.SystemGetPropertyInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinSystemGetPropertyInspectionTest : SystemGetPropertyInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test highlighting`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
fun foo() {
System.<warning descr="Call 'getProperty' can be simplified for 'file.separator'">getProperty</warning>("file.separator")
System.<warning descr="Call 'getProperty' can be simplified for 'path.separator'">getProperty</warning>("path.separator")
System.<warning descr="Call 'getProperty' can be simplified for 'line.separator'">getProperty</warning>("line.separator")
System.<warning descr="Call 'getProperty' can be simplified for 'file.encoding'">getProperty</warning>("file.encoding")
}
""".trimIndent())
}
fun `test quickfix file-separator`() {
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
fun foo() {
System.getPrope<caret>rty("file.separator")
}
""".trimIndent(), """
import java.nio.file.FileSystems
fun foo() {
FileSystems.getDefault().getSeparator()
}
""".trimIndent(), "Replace with 'java.nio.file.FileSystems.getDefault().getSeparator()'", true)
}
fun `test quickfix path-separator`() {
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
fun foo() {
System.getPrope<caret>rty("path.separator")
}
""".trimIndent(), """
import java.io.File
fun foo() {
File.pathSeparator
}
""".trimIndent(), "Replace with 'java.io.File.pathSeparator'", true)
}
fun `test quickfix line-separator`() {
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
fun foo() {
System.getPrope<caret>rty("line.separator")
}
""".trimIndent(), """
fun foo() {
System.lineSeparator()
}
""".trimIndent(), "Replace with 'java.lang.System.lineSeparator()'", true)
}
fun `test quickfix file-encoding`() {
myFixture.testQuickFix(JvmLanguage.KOTLIN, """
fun foo() {
System.getPrope<caret>rty("file.encoding")
}
""".trimIndent(), """
import java.nio.charset.Charset
fun foo() {
Charset.defaultCharset().displayName()
}
""".trimIndent(), "Replace with 'java.nio.charset.Charset.defaultCharset().displayName()'", true)
}
}