Merge pull request #6903 from Maiklins/BAEL-2580

BAEL-2580
This commit is contained in:
Loredana Crusoveanu 2019-05-24 21:48:31 +03:00 committed by GitHub
commit 0f7f90cdfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -5,6 +5,8 @@ import java.util.*
interface Document { interface Document {
@JvmDefault @JvmDefault
fun getTypeDefault() = "document"
fun getType() = "document" fun getType() = "document"
} }
@ -23,9 +25,3 @@ class TextDocument : Document {
} }
class XmlDocument(d : Document) : Document by d class XmlDocument(d : Document) : Document by d
fun main() {
val myDocument = TextDocument()
val myTextDocument = XmlDocument(myDocument)
println("${myDocument.getType()} ${myTextDocument.getType()}")
}

View File

@ -0,0 +1,18 @@
package com.baeldung.range
import org.junit.Test
import kotlin.test.assertEquals
class DocumentTest {
@Test
fun testDefaultMethod() {
val myDocument = TextDocument()
val myTextDocument = XmlDocument(myDocument)
assertEquals("text", myDocument.getType())
assertEquals("text", myTextDocument.getType())
assertEquals("document", myTextDocument.getTypeDefault())
}
}