Skip to content

Commit

Permalink
Add test cases for spacing after setter and getter
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbosch committed Jun 7, 2017
1 parent 9e11dce commit 0a34689
Showing 1 changed file with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.shyiko.ktlint.ruleset.standard

import com.github.shyiko.ktlint.core.LintError
import com.github.shyiko.ktlint.test.lint
import com.github.shyiko.ktlint.test.format
import com.github.shyiko.ktlint.test.lint
import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Test

Expand Down Expand Up @@ -94,5 +94,47 @@ class SpacingAroundKeywordRuleTest {
)
}

@Test
fun noSpaceAfterGetterAndSetterFunction() {
assertThat(SpacingAroundKeywordRule().format(
"""
var x: String
get () {
return ""
}
private set (value) {
x = value
}
""".trimIndent()
)).isEqualTo(
"""
var x: String
get() {
return ""
}
private set(value) {
x = value
}
""".trimIndent()
)
}

@Test
fun visibilityOrInjectProperty() {
assertThat(SpacingAroundKeywordRule().lint(
"""
var setterVisibility: String = "abc"
private set
var setterWithAnnotation: Any? = null
@Inject set
var setterOnNextLine: String
private set
(value) { setterOnNextLine = value}
"""
)).isEqualTo(listOf(
LintError(6, 11, "keyword-spacing", "Missing spacing after \"set\"")
))
}

}

0 comments on commit 0a34689

Please sign in to comment.