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,9 @@
|
||||
//KT-2382
|
||||
|
||||
trait T {
|
||||
final fun foo() = "OK"
|
||||
}
|
||||
|
||||
class S : T { }
|
||||
|
||||
fun box(): String = S().foo()
|
||||
@@ -0,0 +1,10 @@
|
||||
//KT-2206
|
||||
trait A {
|
||||
fun f():Int = 239
|
||||
}
|
||||
|
||||
class B() : A
|
||||
|
||||
fun box() : String {
|
||||
return if (B().f() == 239) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//KT-2206
|
||||
|
||||
trait A {
|
||||
var a:Int
|
||||
get() = 239
|
||||
set(value) {
|
||||
}
|
||||
}
|
||||
|
||||
class B() : A
|
||||
|
||||
fun box() : String {
|
||||
return if (B().a == 239) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
trait MyTrait
|
||||
{
|
||||
var property : String
|
||||
fun foo() = property
|
||||
}
|
||||
|
||||
open class B(param : String) : MyTrait
|
||||
{
|
||||
override var property : String = param
|
||||
override fun foo() = super.foo()
|
||||
}
|
||||
|
||||
fun box()= B("OK").foo()
|
||||
@@ -0,0 +1,15 @@
|
||||
open class MyClass(param : String) {
|
||||
var propterty = param
|
||||
}
|
||||
|
||||
trait MyTrait : MyClass
|
||||
{
|
||||
fun foo() = propterty
|
||||
}
|
||||
|
||||
open class B(param : String) : MyTrait, MyClass(param)
|
||||
{
|
||||
override fun foo() = super<MyTrait>.foo()
|
||||
}
|
||||
|
||||
fun box()= B("OK").foo()
|
||||
@@ -0,0 +1,9 @@
|
||||
trait Flusher {
|
||||
fun flush() = "OK"
|
||||
}
|
||||
|
||||
fun myFlusher() = object : Flusher { }
|
||||
|
||||
fun flushIt(flusher: Flusher) = flusher.flush()
|
||||
|
||||
fun box() = flushIt(myFlusher())
|
||||
@@ -0,0 +1,42 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
class JsonObject {
|
||||
}
|
||||
|
||||
class JsonArray {
|
||||
}
|
||||
|
||||
class ProjectInfo {
|
||||
public fun toString(): String = "OK"
|
||||
}
|
||||
|
||||
public trait Parser<in IN: Any, out OUT: Any> {
|
||||
public fun parse(source: IN): OUT
|
||||
}
|
||||
|
||||
public trait MultiParser<in IN: Any, out OUT: Any> {
|
||||
public fun parse(source: IN): Collection<OUT>
|
||||
}
|
||||
|
||||
public trait JsonParser<T: Any>: Parser<JsonObject, T>, MultiParser<JsonArray, T> {
|
||||
public override fun parse(source: JsonArray): Collection<T> {
|
||||
return ArrayList<T>()
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ProjectInfoJsonParser(): JsonParser<ProjectInfo> {
|
||||
public override fun parse(source: JsonObject): ProjectInfo {
|
||||
return ProjectInfo()
|
||||
}
|
||||
}
|
||||
|
||||
class ProjectApiContext {
|
||||
public val projectInfoJsonParser: ProjectInfoJsonParser = object : ProjectInfoJsonParser(){
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val context = ProjectApiContext()
|
||||
val array = context.projectInfoJsonParser.parse(JsonArray())
|
||||
return if (array != null) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
trait A<T, U> {
|
||||
fun foo(t: T, u: U) = "OK"
|
||||
}
|
||||
|
||||
class B<T> : A<T, Int>
|
||||
|
||||
fun box(): String = B<Int>().foo(1, 2)
|
||||
@@ -0,0 +1,15 @@
|
||||
open class Base
|
||||
|
||||
trait Derived : Base {
|
||||
fun foo(): String {
|
||||
return object {
|
||||
fun bar() = baz(this@Derived)
|
||||
}.bar()
|
||||
}
|
||||
}
|
||||
|
||||
class DerivedImpl : Derived, Base()
|
||||
|
||||
fun baz(b: Base) = "OK"
|
||||
|
||||
fun box() = DerivedImpl().foo()
|
||||
@@ -0,0 +1,21 @@
|
||||
trait AL {
|
||||
fun get(index: Int) : Any? = null
|
||||
}
|
||||
|
||||
trait ALE<T> : AL {
|
||||
fun getOrNull(index: Int, value: T) : T {
|
||||
val r = get(index) as? T
|
||||
return r ?: value
|
||||
}
|
||||
}
|
||||
|
||||
open class SmartArrayList() : ALE<String> {
|
||||
}
|
||||
|
||||
class SmartArrayList2() : SmartArrayList(), AL {
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val c = SmartArrayList2()
|
||||
return if("239" == c.getOrNull(0, "239")) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
trait SimpleClass : java.lang.Object {
|
||||
fun foo() : String = "239 " + toString ()
|
||||
}
|
||||
|
||||
class SimpleClassImpl() : SimpleClass {
|
||||
override fun toString() = "SimpleClassImpl"
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val c = SimpleClassImpl()
|
||||
return if("239 SimpleClassImpl" == c.foo()) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
trait ISized {
|
||||
val size : Int
|
||||
}
|
||||
|
||||
trait javaUtilIterator<T> : Iterator<T> {
|
||||
fun remove() : Unit {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
class MyIterator<T>(val array : ReadOnlyArray<T>) : javaUtilIterator<T> {
|
||||
private var index = 0
|
||||
|
||||
override fun hasNext() : Boolean = index < array.size
|
||||
|
||||
override fun next() : T = array.get(index++)
|
||||
}
|
||||
|
||||
trait ReadOnlyArray<out T> : ISized, Iterable<T> {
|
||||
fun get(index : Int) : T
|
||||
|
||||
override fun iterator() : Iterator<T> = MyIterator<T>(this)
|
||||
}
|
||||
|
||||
trait WriteOnlyArray<in T> : ISized {
|
||||
fun set(index : Int, value : T) : Unit
|
||||
|
||||
fun set(from: Int, count: Int, value: T) {
|
||||
for(i in from..from+count-1) {
|
||||
set(i, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MutableArray<T>(length: Int, init : (Int) -> T) : ReadOnlyArray<T>, WriteOnlyArray<T> {
|
||||
private val array = Array<T>(length, init)
|
||||
|
||||
override fun get(index : Int) : T = array[index]
|
||||
override fun set(index : Int, value : T) : Unit { array[index] = value }
|
||||
|
||||
override val size : Int
|
||||
get() = array.size
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var a = MutableArray<Int> (4, {0})
|
||||
a [0] = 10
|
||||
a.set(1, 2, 13)
|
||||
a [3] = 40
|
||||
System.out?.println(a.iterator())
|
||||
System.out?.println(a.iterator().hasNext())
|
||||
for(el in a) {
|
||||
System.out?.println(el)
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
open class Foo() {
|
||||
public fun k(): String = "K"
|
||||
}
|
||||
|
||||
|
||||
trait T: Foo {
|
||||
public fun xyzzy(): String = o() + k()
|
||||
public fun o(): String
|
||||
}
|
||||
|
||||
class TImpl(): Foo(), T {
|
||||
public override fun o(): String = "O"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TImpl().xyzzy()
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
open class AL<T> {
|
||||
fun get(index: Int) : T? = null
|
||||
}
|
||||
|
||||
trait ALE<T> : AL<T> {
|
||||
fun getOrValue(index: Int, value : T) : T = get(index) ?: value
|
||||
}
|
||||
|
||||
class SmartArrayList() : ALE<String>, AL<String>() {
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val c = SmartArrayList()
|
||||
return if("239" == c.getOrValue(0, "239")) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
open class Base {
|
||||
open fun foo() { }
|
||||
}
|
||||
|
||||
trait Derived : Base {
|
||||
override fun foo() {
|
||||
super.foo()
|
||||
}
|
||||
}
|
||||
|
||||
class DerivedImpl : Derived, Base()
|
||||
|
||||
fun box(): String {
|
||||
DerivedImpl().foo()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
open class Base {
|
||||
open fun foo() { }
|
||||
}
|
||||
|
||||
trait Derived : Base {
|
||||
override fun foo() {
|
||||
object {
|
||||
fun bar() {
|
||||
super<Base>@Derived.foo()
|
||||
}
|
||||
}.bar()
|
||||
}
|
||||
}
|
||||
|
||||
class DerivedImpl : Derived, Base()
|
||||
|
||||
fun box(): String {
|
||||
DerivedImpl().foo()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user