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,53 @@
|
||||
public abstract class FList<T>() {
|
||||
public abstract val head: T
|
||||
public abstract val tail: FList<T>
|
||||
public abstract val empty: Boolean
|
||||
|
||||
class object {
|
||||
val emptyFList = object: FList<Any>() {
|
||||
public override val head: Any
|
||||
get() = throw UnsupportedOperationException();
|
||||
|
||||
public override val tail: FList<Any>
|
||||
get() = this
|
||||
|
||||
public override val empty: Boolean
|
||||
get() = true
|
||||
}
|
||||
}
|
||||
|
||||
public fun plus(head: T): FList<T> = object : FList<T>() {
|
||||
override public val head: T
|
||||
get() = head
|
||||
|
||||
override public val empty: Boolean
|
||||
get() = false
|
||||
|
||||
override public val tail: FList<T>
|
||||
get() = this@FList
|
||||
}
|
||||
}
|
||||
|
||||
public fun <T> emptyFList(): FList<T> = FList.emptyFList as FList<T>
|
||||
|
||||
public fun <T> FList<T>.reverse(where: FList<T> = emptyFList<T>()) : FList<T> =
|
||||
if(empty) where else tail.reverse(where + head)
|
||||
|
||||
public fun <T> FList<T>.iterator(): Iterator<T> = object: Iterator<T> {
|
||||
private var cur: FList<T> = this@iterator
|
||||
|
||||
override public fun next(): T {
|
||||
val res = cur.head
|
||||
cur = cur.tail
|
||||
return res
|
||||
}
|
||||
override public fun hasNext(): Boolean = !cur.empty
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var r = ""
|
||||
for(s in (emptyFList<String>() + "O" + "K").reverse()) {
|
||||
r += s
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public open class Test() {
|
||||
open public fun test() : Unit {
|
||||
System.out?.println(hello)
|
||||
}
|
||||
class object {
|
||||
private val hello : String? = "Hello"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
Test().test()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
public object SomeObject {
|
||||
private val workerThread = object : Thread() {
|
||||
override fun run() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
workerThread.start()
|
||||
}
|
||||
|
||||
private fun foo() : Unit {
|
||||
}
|
||||
}
|
||||
|
||||
public class SomeClass() {
|
||||
inner class Inner {
|
||||
val copy = list
|
||||
}
|
||||
|
||||
private val list = ArrayList<String>()
|
||||
var status : Throwable? = null
|
||||
private val workerThread = object : Thread() {
|
||||
public override fun run() {
|
||||
try {
|
||||
list.add("123")
|
||||
list.add("33")
|
||||
Inner().copy.add("444")
|
||||
}
|
||||
catch(t: Throwable) {
|
||||
status = t
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
workerThread.start()
|
||||
workerThread.join()
|
||||
}
|
||||
}
|
||||
|
||||
public fun box():String {
|
||||
var obj = SomeClass()
|
||||
return if(obj.status == null) "OK" else {
|
||||
obj.status?.printStackTrace()
|
||||
"failed"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
enum class Color(val rgb : Int) {
|
||||
RED : Color(0xFF0000)
|
||||
GREEN : Color(0x00FF00)
|
||||
BLUE : Color(0x0000FF)
|
||||
}
|
||||
|
||||
enum class Direction {
|
||||
NORTH
|
||||
SOUTH
|
||||
WEST
|
||||
EAST
|
||||
}
|
||||
|
||||
fun bar(c: Color) = when (c) {
|
||||
Color.RED -> 1
|
||||
Color.GREEN -> 2
|
||||
Color.BLUE -> 3
|
||||
}
|
||||
|
||||
fun foo(d: Direction) = when(d) {
|
||||
Direction.NORTH -> 1
|
||||
Direction.SOUTH -> 2
|
||||
Direction.WEST -> 3
|
||||
Direction.EAST -> 4
|
||||
}
|
||||
|
||||
fun box() : String =
|
||||
if (foo(Direction.EAST) == 4 && bar(Color.GREEN) == 2) "OK" else "fail"
|
||||
@@ -0,0 +1,8 @@
|
||||
abstract class Foo<T> {
|
||||
fun hello(id: T) = "O$id"
|
||||
}
|
||||
|
||||
class Bar: Foo<String>() {
|
||||
}
|
||||
|
||||
fun box() = Bar().hello("K")
|
||||
@@ -0,0 +1,13 @@
|
||||
fun box(): String {
|
||||
return object {
|
||||
fun foo(): String {
|
||||
val f = {}
|
||||
object : Runnable {
|
||||
public override fun run() {
|
||||
f()
|
||||
}
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
}.foo()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class C {
|
||||
public object Obj {
|
||||
val o = "O"
|
||||
|
||||
object InnerObj {
|
||||
fun k() = "K"
|
||||
}
|
||||
|
||||
class D {
|
||||
val ko = "KO"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val res = C().Obj.o + C().Obj.InnerObj.k() + C().Obj.D().ko
|
||||
return if (res == "OKKO") "OK" else "Fail: $res"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box() : String {
|
||||
var a = 1
|
||||
|
||||
object {
|
||||
{
|
||||
a = 2
|
||||
}
|
||||
}
|
||||
return if (a == 2) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box() : String {
|
||||
var a = 1
|
||||
|
||||
(object: Runnable {
|
||||
override public fun run() {
|
||||
a = 2
|
||||
}
|
||||
}).run()
|
||||
return if (a == 2) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class A() {
|
||||
|
||||
fun ok() = Foo.Bar.bar() + Foo.Bar.barv
|
||||
|
||||
private object Foo {
|
||||
fun foo() = "O"
|
||||
val foov = "K"
|
||||
|
||||
public object Bar {
|
||||
fun bar() = foo()
|
||||
val barv = foov
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = A().ok()
|
||||
@@ -0,0 +1,9 @@
|
||||
class Clazz {
|
||||
class object {
|
||||
val a = object {
|
||||
fun run(x: String) = x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = "OK"
|
||||
@@ -0,0 +1,7 @@
|
||||
open class A {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box() = object : A() {
|
||||
fun bar() = super<A>.foo()
|
||||
}.bar()
|
||||
@@ -0,0 +1,12 @@
|
||||
object Obj {
|
||||
class Inner() {
|
||||
fun ok() = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val klass = Class.forName("Obj\$Inner")!!
|
||||
val cons = klass.getConstructors()!![0]
|
||||
val inner = cons.newInstance(* Array(0){""})
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
class Identifier<T>(t : T?, myHasDollar : Boolean) {
|
||||
private val myT : T?
|
||||
|
||||
public fun getName() : T? { return myT }
|
||||
|
||||
class object {
|
||||
open public fun init<T>(name : T?) : Identifier<T> {
|
||||
val __ = Identifier<T>(name, false)
|
||||
return __
|
||||
}
|
||||
}
|
||||
{
|
||||
$myT = t
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var i3 : Identifier<String?>? = Identifier.init<String?>("name")
|
||||
System.out?.println(i3?.getName())
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package while_bug_1
|
||||
|
||||
import java.io.*
|
||||
|
||||
open class AllEvenNum() {
|
||||
|
||||
class object {
|
||||
open public fun main(args : Array<String?>?) : Unit {
|
||||
var i : Int = 1
|
||||
while ((i <= 100)) {
|
||||
{
|
||||
if (((i % 2) == 0))
|
||||
{
|
||||
System.out?.print((i.toString() + ","))
|
||||
}
|
||||
|
||||
}
|
||||
(i = i + 1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
AllEvenNum.main(arrayOfNulls<String>(0))
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package demo
|
||||
|
||||
public open class Identifier<T>(myName : T?, myHasDollar : Boolean) {
|
||||
private val myName : T?
|
||||
private var myHasDollar : Boolean
|
||||
private var myNullable : Boolean = true
|
||||
|
||||
{
|
||||
$myName = myName
|
||||
$myHasDollar = myHasDollar
|
||||
}
|
||||
|
||||
open public fun getName() : T? {
|
||||
return myName
|
||||
}
|
||||
|
||||
class object {
|
||||
open public fun init<T>(name : T?) : Identifier<T> {
|
||||
val __ = Identifier<T>(name, false)
|
||||
return __
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var i3 : Identifier<*>? = Identifier.init<String?>("name")
|
||||
System.out?.println("Hello, " + i3?.getName())
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
enum class Test {
|
||||
A
|
||||
B
|
||||
C
|
||||
}
|
||||
|
||||
fun checkA(a: Test) = when(a) {
|
||||
Test.B -> false
|
||||
Test.A -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
if(!checkA(Test.A)) return "fail"
|
||||
if( checkA(Test.C)) return "fail"
|
||||
if( checkA(Test.B)) return "fail"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
object A {
|
||||
fun result() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = A.result()
|
||||
@@ -0,0 +1,17 @@
|
||||
class C(x: Int, val y : Int) {
|
||||
fun initChild(var x: Int) : java.lang.Object {
|
||||
return object : java.lang.Object() {
|
||||
override fun toString(): String? {
|
||||
x = x + y
|
||||
return "child" + x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val child = initChild(x)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C(10,3)
|
||||
return if (c.child.toString() == "child13" && c.child.toString() == "child16" && c.child.toString() == "child19") "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package p
|
||||
|
||||
class C(val y : Int) {
|
||||
val initChild = { ->
|
||||
object : java.lang.Object() {
|
||||
override fun toString(): String {
|
||||
return "child" + y
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C(3).initChild
|
||||
val x = c().toString()
|
||||
return if(x == "child3") "OK" else x
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
open class A(open val v: String)
|
||||
|
||||
fun A.a(newv: String) = object: A("fail") {
|
||||
override val v = this@a.v + newv
|
||||
}
|
||||
|
||||
fun box() = A("O").a("K").v
|
||||
@@ -0,0 +1,7 @@
|
||||
object A {
|
||||
val x: Int = 610
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return if (A.x != 610) "fail" else "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
open class A(open val v: String) {
|
||||
}
|
||||
|
||||
open class B(open val v: String) {
|
||||
fun a(newv: String) = object: A("fail") {
|
||||
override val v = this@B.v + newv
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = B("O").a("K").v
|
||||
Reference in New Issue
Block a user