Kapt: Add test on Map<Key, Intf> and MutableMap<Key, Intf>

(cherry picked from commit 59cdbcb)
This commit is contained in:
Yan Zhulanow
2016-09-21 21:21:06 +03:00
committed by Yan Zhulanow
parent 30ed279426
commit a22721fbd8
3 changed files with 29 additions and 1 deletions
@@ -142,7 +142,11 @@ abstract class AbstractProcessorTest : AbstractBytecodeTextTest() {
fail("Annotation processor " + (if (shouldRun) "was not started" else "was started"))
}
}
protected fun TypeElement.findMethods(name: String): List<JeMethodExecutableElement> {
return enclosedElements.filterIsInstance<JeMethodExecutableElement>().filter { it.simpleName.toString() == name }
}
protected fun TypeElement.findMethod(name: String, vararg parameterTypes: String): JeMethodExecutableElement {
return enclosedElements.first {
if (it !is JeMethodExecutableElement
@@ -333,4 +333,16 @@ class ProcessorTests : AbstractProcessorTest() {
testDisposable("getBindingContext")
}
}
fun testMapMutableMap() = test("MapMutableMap", "*") { set, roundEnv, env ->
val test = env.findClass("Test")
fun test(name: String, expected: String) {
assertEquals(expected, test.findMethods(name).single().parameters.single().asType().toString())
}
test("a", "java.util.Map<java.lang.Integer,? extends Intf>")
test("b", "java.util.Map<java.lang.Integer,Intf>")
test("c", "java.util.Map<java.lang.Integer,Test>")
test("d", "java.util.Map<java.lang.Integer,Test>")
}
}