Skip to content

Commit

Permalink
Add convenience modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkoutso committed Dec 14, 2023
1 parent ca3933f commit 0d71e7e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/io/outfoxx/swiftpoet/Modifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ enum class Modifier(

REQUIRED("required", Target.FUNCTION),

CONVENIENCE("convenience", Target.FUNCTION),

INOUT("inout", Target.PARAMETER),

WEAK("weak", Target.PROPERTY),
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/io/outfoxx/swiftpoet/test/FunctionSpecTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,28 @@ class FunctionSpecTests {
)
}

@Test
@DisplayName("Generates constructor with convenience modifier")
fun testConvenienceModifier() {
val testFunc = FunctionSpec.constructorBuilder()
.addModifiers(Modifier.PUBLIC, Modifier.CONVENIENCE)
.build()

val out = StringWriter()
testFunc.emit(CodeWriter(out), setOf())

assertThat(
out.toString(),
equalTo(
"""
public convenience init() {
}
""".trimIndent()
)
)
}

@Test
@DisplayName("Generates decorators formatted")
fun testGenDecorators() {
Expand Down

0 comments on commit 0d71e7e

Please sign in to comment.