Move blackBoxFile() testData to box/ directory
Delete all test methods (and empty test classes), since they'll be auto-generated
This commit is contained in:
committed by
Alexander Udalov
parent
ecbb2f10ef
commit
41a416da60
@@ -0,0 +1,7 @@
|
||||
//KT-1061 Can't call function defined as a val
|
||||
|
||||
object X {
|
||||
val doit = { (i: Int) -> i }
|
||||
}
|
||||
|
||||
fun box() : String = if (X.doit(3) == 3) "OK" else "fail"
|
||||
@@ -0,0 +1,12 @@
|
||||
//KT-1249 IllegalStateException invoking function property
|
||||
class TestClass(val body : () -> Unit) : Any() {
|
||||
fun run() {
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
TestClass({}).run()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//KT-1290 Method property in constructor causes NPE
|
||||
|
||||
class Foo<T>(val filter: (T) -> Boolean) {
|
||||
public fun bar(tee: T) : Boolean {
|
||||
return filter(tee);
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() = Foo({ (i: Int) -> i < 5 }).bar(2)
|
||||
|
||||
fun box() : String {
|
||||
if (!foo()) return "fail"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun box(): String {
|
||||
val sb = StringBuilder()
|
||||
fun String.plus() {
|
||||
sb.append(this)
|
||||
}
|
||||
|
||||
+"OK"
|
||||
return sb.toString()!!
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
private val sb: StringBuilder = StringBuilder()
|
||||
|
||||
fun String.plus() {
|
||||
sb.append(this)
|
||||
}
|
||||
|
||||
fun foo(): String {
|
||||
+"OK"
|
||||
return sb.toString()!!
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String = A().foo()
|
||||
@@ -0,0 +1,18 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box() : String {
|
||||
val array = ArrayList<String>()
|
||||
array.add("0")
|
||||
array.add("1")
|
||||
array.add("2")
|
||||
array.last = "5"
|
||||
return if(array.length == 3 && array.last == "5") "OK" else "fail"
|
||||
}
|
||||
|
||||
var <T> ArrayList<T>.length : Int
|
||||
get() = size()
|
||||
set(value: Int) = throw java.lang.Error()
|
||||
|
||||
var <T> ArrayList<T>.last : T
|
||||
get() = get(size()-1)!!
|
||||
set(el : T) { set(size()-1, el) }
|
||||
@@ -0,0 +1,29 @@
|
||||
package kt606
|
||||
|
||||
//KT-606 wrong resolved call
|
||||
|
||||
class StandardPipelineFactory(val config : ChannelPipeline.() -> Unit) : ChannelPipelineFactory {
|
||||
override fun getPipeline() : ChannelPipeline {
|
||||
val pipeline : ChannelPipeline = DefaultChannelPipeline()
|
||||
pipeline.config()
|
||||
return pipeline
|
||||
}
|
||||
}
|
||||
|
||||
trait ChannelPipeline {
|
||||
fun print(any: Any)
|
||||
}
|
||||
|
||||
class DefaultChannelPipeline : ChannelPipeline {
|
||||
override fun print(any: Any) = System.out?.println(any)
|
||||
|
||||
}
|
||||
|
||||
trait ChannelPipelineFactory {
|
||||
fun getPipeline() : ChannelPipeline
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
StandardPipelineFactory({ print("OK") }).getPipeline()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import java.util.*
|
||||
|
||||
class Template() {
|
||||
val collected = ArrayList<String>()
|
||||
|
||||
fun String.plus() {
|
||||
collected.add(this@plus)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
+ "239"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val u = Template()
|
||||
u.test()
|
||||
return if(u.collected.size() == 1 && u.collected.get(0) == "239") "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun box() : String {
|
||||
val y = 12
|
||||
val op = { (x:Int) -> (x + y).toString() }
|
||||
|
||||
val op2 : Int.(Int) -> String = { op(this + it) }
|
||||
|
||||
return if("27" == 5.op2(10)) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fun <T> T.mustBe(t : T) {
|
||||
assert("$this must be $t") {this == t}
|
||||
}
|
||||
|
||||
inline fun assert(message : String, condition : () -> Boolean) {
|
||||
if (!condition())
|
||||
throw AssertionError(message)
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
"lala" mustBe "lala"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
class Request(val path: String) {
|
||||
|
||||
}
|
||||
|
||||
class Handler() {
|
||||
fun Int.times(op: ()-> Unit) {
|
||||
for(i in 0..this)
|
||||
op()
|
||||
}
|
||||
|
||||
// fun Request.getPath() : String {
|
||||
// val sb = java.lang.StringBuilder()
|
||||
// 10.times {
|
||||
// sb.append(path)?.append(this)
|
||||
// }
|
||||
// return sb.toString() as String
|
||||
// }
|
||||
|
||||
fun Request.getPath() = path
|
||||
|
||||
fun test(request: Request) = request.getPath()
|
||||
}
|
||||
|
||||
fun box() : String = if(Handler().test(Request("239")) == "239") "OK" else "fail"
|
||||
Reference in New Issue
Block a user