Rewrite className helper to fix tests on android
Since android tests preprocess test data and (at least) replace package for files and fix package usages it's preferred to use fqnames explicitly instead of assembly them from parts, as it was before.
This commit is contained in:
Vendored
+3
-3
@@ -17,13 +17,13 @@ fun box(): String {
|
||||
val type = test<Any>()
|
||||
val x = type.arguments.single().type!!.classifier as KTypeParameter
|
||||
|
||||
val expected = className("kotlin", "Any?")
|
||||
val expected = className("kotlin.Any?")
|
||||
assertEquals(expected, x.upperBounds.joinToString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun className(qualifier: String, name: String): String {
|
||||
fun className(fqName: String): String {
|
||||
val isJS = 1 as Any is Double
|
||||
return if (isJS) name else "$qualifier.$name"
|
||||
return if (isJS) fqName.substringAfterLast('.') else fqName
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -16,13 +16,13 @@ class C<X> {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val fqn = className("test", "Container")
|
||||
val fqn = className("test.Container")
|
||||
assertEquals("$fqn<X>", C<Any>().notNull().toString())
|
||||
assertEquals("$fqn<X?>", C<Any>().nullable().toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun className(qualifier: String, name: String): String {
|
||||
fun className(fqName: String): String {
|
||||
val isJS = 1 as Any is Double
|
||||
return if (isJS) name else "$qualifier.$name"
|
||||
return if (isJS) fqName.substringAfterLast('.') else fqName
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -14,13 +14,13 @@ fun <X1> notNull() = typeOf<Container<X1>>()
|
||||
fun <X2> nullable() = typeOf<Container<X2?>>()
|
||||
|
||||
fun box(): String {
|
||||
val fqn = className("test", "Container")
|
||||
val fqn = className("test.Container")
|
||||
assertEquals("$fqn<X1>", notNull<Any>().toString())
|
||||
assertEquals("$fqn<X2?>", nullable<Any>().toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun className(qualifier: String, name: String): String {
|
||||
fun className(fqName: String): String {
|
||||
val isJS = 1 as Any is Double
|
||||
return if (isJS) name else "$qualifier.$name"
|
||||
return if (isJS) fqName.substringAfterLast('.') else fqName
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -14,13 +14,13 @@ val <X1> X1.notNull get() = typeOf<Container<X1>>()
|
||||
val <X2> X2.nullable get() = typeOf<Container<X2?>>()
|
||||
|
||||
fun box(): String {
|
||||
val fqn = className("test", "Container")
|
||||
val fqn = className("test.Container")
|
||||
assertEquals("$fqn<X1>", "".notNull.toString())
|
||||
assertEquals("$fqn<X2?>", "".nullable.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun className(qualifier: String, name: String): String {
|
||||
fun className(fqName: String): String {
|
||||
val isJS = 1 as Any is Double
|
||||
return if (isJS) name else "$qualifier.$name"
|
||||
return if (isJS) fqName.substringAfterLast('.') else fqName
|
||||
}
|
||||
|
||||
+6
-6
@@ -16,25 +16,25 @@ fun <X, Y, Z> test() where X : Y?, Y : List<Z>, Z : Set<String>
|
||||
|
||||
fun box(): String {
|
||||
val type = test<MutableList<Set<String>>?, MutableList<Set<String>>, Set<String>>()
|
||||
val containerNmae = className("test", "Container")
|
||||
val containerNmae = className("test.Container")
|
||||
assertEquals("$containerNmae<X>", type.toString())
|
||||
|
||||
val x = type.arguments.single().type!!.classifier as KTypeParameter
|
||||
assertEquals("Y?", x.upperBounds.joinToString())
|
||||
|
||||
val y = x.upperBounds.single().classifier as KTypeParameter
|
||||
val listName = className("kotlin.collections", "List")
|
||||
val listName = className("kotlin.collections.List")
|
||||
assertEquals("$listName<Z>", y.upperBounds.joinToString())
|
||||
|
||||
val z = y.upperBounds.single().arguments.single().type!!.classifier as KTypeParameter
|
||||
val setName = className("kotlin.collections", "Set")
|
||||
val stringName = className("kotlin", "String")
|
||||
val setName = className("kotlin.collections.Set")
|
||||
val stringName = className("kotlin.String")
|
||||
assertEquals("$setName<$stringName>", z.upperBounds.joinToString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun className(qualifier: String, name: String): String {
|
||||
fun className(fqName: String): String {
|
||||
val isJS = 1 as Any is Double
|
||||
return if (isJS) name else "$qualifier.$name"
|
||||
return if (isJS) fqName.substringAfterLast('.') else fqName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user