Add tests for types in chains of collection transformation calls

This commit is contained in:
Vitaliy.Bibaev
2017-11-17 18:27:46 +03:00
committed by Yan Zhulanow
parent 25024ff9a0
commit d14cc77003
27 changed files with 125 additions and 0 deletions
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
<caret> listOf("abc").count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
<caret> listOf("abc", null).count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
bo<caret>oleanArrayOf(true, true, false).count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
s<caret>etOf(1.toByte(), 20.toByte()).forEach { }
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
charArra<caret>yOf('a', 'b', 'c').count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
Doub<caret>leArray(10).count()
}
@@ -0,0 +1,7 @@
fun main(args: Array<String>) {
byteArray<caret>Of(10, 20)
.map { it.toString() }
.map { if (it == "10") null else 10 }
.map { 10 }
.contains(200)
}
@@ -0,0 +1,6 @@
fun main(args: Array<String>) {
"jetBrains".map { it.isLowerCase() }
.flat<caret>Map { linkedSetOf(1.2, 3.0) }
.map { it.toString() }
.count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(1.<caret>0f).contains(2.0f)
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
intArrayOf<caret>(10).get(0)
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
longArrayOf(1L, 2L<caret>).count { it < 2 }
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
sortedSetOf(10.0).m<caret>ap { null }.count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
lis<caret>tOf(Any(), null).contains(10)
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
lis<caret>tOf(Any(), null).map { 10 }.contains(10)
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(true, nul<caret>l, false).count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(1.to<caret>Byte(), null).forEach { }
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(','<caret>, '.', null).component1()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(0.4, null)<caret>.component2()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(0.4f, null).indexOf(0<caret>.3f)
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
<caret> listOf(5, null).lastIndexOf(null)
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listO<caret>f(10L, null).isNotEmpty()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(6.toShort<caret>(), null).last()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(0.4, null).<caret>map { 10 }.count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(20, 30).m<caret>ap { Any() }.contains(Any())
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
listOf(20, 30).map { it.toStrin<caret>g().toByteOrNull() }.count()
}
@@ -0,0 +1,3 @@
fun main(args: Array<String>) {
shortArrayOf(1.toShor<caret>t(), 2.toShort()).single()
}
@@ -2,6 +2,7 @@ package com.intellij.debugger.streams.kotlin.psi.collection
import com.intellij.debugger.streams.kotlin.lib.KotlinCollectionSupportProvider
import com.intellij.debugger.streams.kotlin.psi.TypedChainTestCase
import com.intellij.debugger.streams.kotlin.trace.dsl.KotlinTypes
import com.intellij.debugger.streams.wrapper.StreamChainBuilder
/**
@@ -9,4 +10,43 @@ import com.intellij.debugger.streams.wrapper.StreamChainBuilder
*/
class TypedCollectionChainTest : TypedChainTestCase("collection/positive/types") {
override val kotlinChainBuilder: StreamChainBuilder = KotlinCollectionSupportProvider().chainBuilder
fun testAny() = doTest(KotlinTypes.ANY)
fun testNullableAny() = doTest(KotlinTypes.NULLABLE_ANY)
fun testBoolean() = doTest(KotlinTypes.BOOLEAN)
fun testNullableBoolean() = doTest(KotlinTypes.NULLABLE_ANY)
fun testByte() = doTest(KotlinTypes.BYTE)
fun testNullableByte() = doTest(KotlinTypes.NULLABLE_ANY)
fun testShort() = doTest(KotlinTypes.SHORT)
fun testNullableShort() = doTest(KotlinTypes.NULLABLE_ANY)
fun testInt() = doTest(KotlinTypes.INT)
fun testNullableInt() = doTest(KotlinTypes.NULLABLE_ANY)
fun testLong() = doTest(KotlinTypes.LONG)
fun testNullableLong() = doTest(KotlinTypes.NULLABLE_ANY)
fun testFloat() = doTest(KotlinTypes.FLOAT)
fun testNullableFloat() = doTest(KotlinTypes.NULLABLE_ANY)
fun testDouble() = doTest(KotlinTypes.DOUBLE)
fun testNullableDouble() = doTest(KotlinTypes.NULLABLE_ANY)
fun testChar() = doTest(KotlinTypes.CHAR)
fun testNullableChar() = doTest(KotlinTypes.NULLABLE_ANY)
fun testNullableAnyToPrimitive() = doTest(KotlinTypes.NULLABLE_ANY, KotlinTypes.BOOLEAN)
fun testPrimitiveToNullableAny() = doTest(KotlinTypes.INT, KotlinTypes.NULLABLE_ANY)
fun testAnyToPrimitive() = doTest(KotlinTypes.ANY, KotlinTypes.BOOLEAN)
fun testPrimitiveToAny() = doTest(KotlinTypes.INT, KotlinTypes.ANY)
fun testNullableToNotNull() = doTest(KotlinTypes.NULLABLE_ANY, KotlinTypes.INT)
fun testNotNullToNullable() = doTest(KotlinTypes.DOUBLE, KotlinTypes.NULLABLE_ANY)
fun testFewTransitions1() = doTest(KotlinTypes.BYTE, KotlinTypes.ANY, KotlinTypes.NULLABLE_ANY, KotlinTypes.INT)
fun testFewTransitions2() = doTest(KotlinTypes.CHAR, KotlinTypes.BOOLEAN, KotlinTypes.DOUBLE, KotlinTypes.ANY)
}