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,52 @@
|
||||
class A {
|
||||
private var foo = 1
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
foo = 5
|
||||
foo
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
private val foo = 1
|
||||
get
|
||||
|
||||
fun foo() {
|
||||
foo
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
private var foo = 1
|
||||
get
|
||||
set
|
||||
|
||||
fun foo() {
|
||||
foo = 2
|
||||
foo
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
private var foo = 1
|
||||
set(i: Int) {
|
||||
foo = i + 1
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
foo = 5
|
||||
foo
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
A().foo()
|
||||
B().foo()
|
||||
C().foo()
|
||||
D().foo()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class D {
|
||||
var foo = 1
|
||||
private set
|
||||
|
||||
fun foo() {
|
||||
foo = 2
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
D().foo()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public object RefreshQueue {
|
||||
private val workerThread: Thread = Thread(object : Runnable {
|
||||
override fun run() {
|
||||
workerThread.isInterrupted()
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
workerThread.start()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
RefreshQueue
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public abstract class VirtualFile() {
|
||||
public abstract val size : Long
|
||||
}
|
||||
|
||||
public class PhysicalVirtualFile : VirtualFile() {
|
||||
public override val size: Long
|
||||
get() = 11
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
PhysicalVirtualFile()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public abstract class BaseClass() {
|
||||
protected abstract val kind : String
|
||||
|
||||
protected open val kind2 : String = " kind1"
|
||||
|
||||
fun debug() = kind + kind2
|
||||
}
|
||||
|
||||
public class Subclass : BaseClass() {
|
||||
override val kind : String = "Physical"
|
||||
|
||||
override val kind2 : String = " kind2"
|
||||
}
|
||||
|
||||
fun box():String = if(Subclass().debug() == "Physical kind2") "OK" else "fail"
|
||||
@@ -0,0 +1,16 @@
|
||||
public abstract class BaseClass() {
|
||||
open val kind : String = "BaseClass "
|
||||
|
||||
fun getKindValue() : String {
|
||||
return kind
|
||||
}
|
||||
}
|
||||
|
||||
public class Subclass : BaseClass() {
|
||||
override val kind : String = "Subclass "
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val r = Subclass().getKindValue() + Subclass().kind
|
||||
return if(r == "Subclass Subclass ") "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
open class Base(val bar: String)
|
||||
|
||||
class Foo(bar: String) : Base(bar) {
|
||||
fun something() = (bar as java.lang.String).toUpperCase()
|
||||
}
|
||||
|
||||
fun box() = Foo("ok").something()
|
||||
@@ -0,0 +1,9 @@
|
||||
package pack
|
||||
|
||||
open class A(val value: String )
|
||||
|
||||
class B(value: String) : A(value) {
|
||||
fun toString() = "B($value)";
|
||||
}
|
||||
|
||||
fun box() = if (B("4").toString() == "B(4)") "OK" else "fail"
|
||||
@@ -0,0 +1,21 @@
|
||||
abstract class ClassValAbstract {
|
||||
abstract var a: Int
|
||||
|
||||
class object {
|
||||
val methods = (this as java.lang.Object).getClass()?.getClassLoader()?.loadClass("ClassValAbstract")?.getMethods()!!
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
for(m in ClassValAbstract.methods) {
|
||||
if (m!!.getName() == "getA") {
|
||||
if(m!!.getModifiers() != 1025)
|
||||
return "get failed"
|
||||
}
|
||||
if (m!!.getName() == "setA") {
|
||||
if(m!!.getModifiers() != 1025)
|
||||
return "set failed"
|
||||
}
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
trait A {
|
||||
val method : (() -> Unit )?
|
||||
val test : Integer
|
||||
}
|
||||
|
||||
class AImpl : A {
|
||||
override val method : (() -> Unit )? = {
|
||||
}
|
||||
override val test : Integer = Integer(777)
|
||||
}
|
||||
|
||||
fun test(a : A) {
|
||||
val method = a.method
|
||||
if (method != null) {
|
||||
method()
|
||||
}
|
||||
}
|
||||
|
||||
public fun box() : String {
|
||||
AImpl().test
|
||||
test(AImpl())
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
trait A {
|
||||
val v: Int
|
||||
}
|
||||
|
||||
class AImpl : A {
|
||||
override val v: Int = 5
|
||||
}
|
||||
|
||||
public fun box() : String {
|
||||
(AImpl() : A).v
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
val Int.ext : () -> Int = { 5 }
|
||||
val Long.ext : Long = 4.ext().toLong() //(c.kt:4)
|
||||
val y : Long = 10.toLong().ext
|
||||
|
||||
fun box() : String = if (y == 5.toLong()) "OK" else "fail"
|
||||
@@ -0,0 +1,14 @@
|
||||
class P {
|
||||
var x : Int = 0
|
||||
private set
|
||||
|
||||
fun foo() {
|
||||
({ x = 4 })()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val p = P()
|
||||
p.foo()
|
||||
return if (p.x == 4) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
class A<T>(var t: T) {}
|
||||
class B<R>(val r: R) {}
|
||||
|
||||
fun box() : String {
|
||||
val ai = A<Int>(1)
|
||||
val aai = A<A<Int>>(ai)
|
||||
if(aai.t.t != 1) return "fail"
|
||||
/*
|
||||
aai.t.t = 2
|
||||
if(aai.t.t != 2) return "fail"
|
||||
|
||||
if(ai.t != 2) return "fail"
|
||||
if(aai.t != ai) return "fail"
|
||||
if(aai.t !== ai) return "fail"
|
||||
|
||||
val abi = A<B<Int>>(B<Int>(1))
|
||||
if(abi.t.r != 1) return "fail"
|
||||
*/
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
trait TextField {
|
||||
fun getText(): String
|
||||
fun setText(text: String)
|
||||
}
|
||||
|
||||
class SimpleTextField : TextField {
|
||||
private var text = ""
|
||||
override fun getText() = text
|
||||
override fun setText(text: String) {
|
||||
this.text = text
|
||||
}
|
||||
}
|
||||
|
||||
class TextFieldWrapper(textField: TextField) : TextField by textField
|
||||
|
||||
fun box() : String {
|
||||
val textField = TextFieldWrapper(SimpleTextField())
|
||||
textField.setText("OK")
|
||||
return textField.getText()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
trait FooTrait {
|
||||
val propertyTest: String
|
||||
}
|
||||
|
||||
class FooDelegate: FooTrait {
|
||||
override val propertyTest: String = "OK"
|
||||
}
|
||||
|
||||
class DelegateTest(): FooTrait by FooDelegate() {
|
||||
fun test() = propertyTest
|
||||
}
|
||||
|
||||
fun box() = DelegateTest().test()
|
||||
@@ -0,0 +1,16 @@
|
||||
open class A
|
||||
class B : A() {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
class Test {
|
||||
val a : A = B()
|
||||
private val b : B get() = a as B //'private' is important here
|
||||
|
||||
fun outer() : Int {
|
||||
fun inner() : Int = b.foo() //'no such field error' here
|
||||
return inner()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if (Test().outer() == 1) "OK" else "fail"
|
||||
@@ -0,0 +1,15 @@
|
||||
package name
|
||||
|
||||
class Test() {
|
||||
var i = 5
|
||||
val ten = 10.toLong()
|
||||
|
||||
fun Long.t() = this.toInt() + i++ + ++i
|
||||
|
||||
fun tt() = ten.t()
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var m = Test()
|
||||
return if((m.i)++ == 5 && ++(m.i) == 7 && m.tt() == 26) "OK" else "fail"
|
||||
}
|
||||
Reference in New Issue
Block a user