Add test methods and data for uncommon cases

Uncommon means mostly that aren't present in raw fir builder data
This commit is contained in:
Ivan Cilcic
2019-08-15 13:45:22 +03:00
committed by Mikhail Glukhikh
parent 8047aa22a4
commit aebe8c36f5
15 changed files with 474 additions and 0 deletions
@@ -0,0 +1,36 @@
package p
class A {
val aProp = 10
}
class B {
val bProp = 1
}
fun foo(a: Int, b: Int): Int {
with(A()) {
aProp
with(B()) {
aProp
bProp
aProp
}
}
with(A()) {
aProp
with(B()) {
aProp
bProp
}
with(B()) {
aProp
bProp
}
}
return a
}
@@ -0,0 +1,12 @@
package org.jetbrains.kotlin.test
val listOfInt = listOf(1, 2, 3)
val javaList = java.util.ArrayList<Int>()
fun move(): java.util.ArrayList<Int> {
for (elem in listOfInt) {
javaList.add(elem)
}
return javaList
}
@@ -0,0 +1,34 @@
package org.jetbrains.kotlin.test
val p1 = 10
val p2: Double = 1.0
val p3: Float = 2.5f
val p4 = "some string"
val p5 = p1 + p2
val p6 = p1 * p2 + (p5 - p3)
val withGetter
get() = p1 * p3
var withSetter
get() = p4
set(value) = value
val withGetter2: Boolean
get() {
return true
}
var withSetter2: String
get() = "1"
set(value) {
field = value + "!"
}
private val privateGetter: String = "cba"
get
var privateSetter: String = "abc"
private set
@@ -0,0 +1,15 @@
package org.jetbrains.kotlin.test
abstract class Base<T>(var x: T) {
fun replace(newValue: T)
}
class Derived(var x: Int): Base<Int>() {
override fun replace(newValue: Int) {
x = newValue
}
}
fun test() {
Derived(10).replace(20)
}
@@ -0,0 +1,16 @@
interface Source<out T> {
fun nextT(): T
}
fun demo(strs: Source<String>) {
val objects: Source<Any> = strs
}
interface Comparable<in T> {
operator fun compareTo(other: T): Int
}
fun demo(x: Comparable<Number>) {
x.compareTo(1.0)
val y: Comparable<Double> = x
}
@@ -0,0 +1,10 @@
fun <T> copyWhenGreater(list: List<T>, threshold: T): List<String>
where T : CharSequence,
T : Comparable<T> {
return list.filter { it > threshold }.map { it.toString() }
}
fun main() {
val list = listOf("1", "2", "3")
val copy = copyWhenGreater(list, "2")
}