add test files

This commit is contained in:
pTalanov
2012-02-27 21:55:57 +04:00
parent 645a3a9f2f
commit c21ea8aa86
240 changed files with 16998 additions and 0 deletions
@@ -0,0 +1,21 @@
package foo
open class A() {
val value = "BAR"
}
trait Test {
fun addFoo(s:String) : String {
return s + "FOO"
}
}
class B() : A(), Test {
fun eval() : String {
return addFoo(value);
}
}
fun box() = B().eval() == "BARFOO"
@@ -0,0 +1,21 @@
package foo
open class A() {
val value = "BAR"
}
trait Test {
fun addFoo(s:String) : String {
return s + "FOO"
}
}
class B() : Test, A() {
fun eval() : String {
return addFoo(value);
}
}
fun box() = B().eval() == "BARFOO"
@@ -0,0 +1,41 @@
package foo
class C() : B() {
{
order = order + "C"
}
}
class D() : B() {
{
order = order + "D"
}
}
class E() : A() {
{
order = order + "E"
}
}
open class B() : A(), F {
{
order = order + "B"
}
}
open class A() : F {
var order = ""
{
order = order + "A"
}
}
trait F {
fun bar() = "F"
}
fun box() : Boolean {
return (C().order == "ABC") && (D().order == "ABD") && (E().order == "AE") && (C().bar() == "F") && (A().bar() == "F")
}
@@ -0,0 +1,13 @@
package foo
trait AL {
fun get(index: Int) : Any? = null
}
class SmartArrayList() : AL {
}
fun box() : Boolean {
val c = SmartArrayList()
return (null == c.get(0))
}
@@ -0,0 +1,19 @@
package foo
open class Base() {
fun n(n : Int) : Int = n + 1
}
trait Abstract {}
class Derived1() : Base(), Abstract {}
class Derived2() : Abstract, Base() {}
fun test(s : Base) : Boolean = s.n(238) == 239
fun box() : String {
if (!test(Base())) return "Fail #1"
if (!test(Derived1())) return "Fail #2"
if (!test(Derived2())) return "Fail #3"
return "OK"
}
@@ -0,0 +1,21 @@
package foo
trait Test {
fun addFoo(s:String) : String {
return s + "FOO"
}
fun addBar(s:String) : String {
return s + "BAR"
}
}
class A() : Test {
val string = "TEST"
fun value() : String {
return addBar(addFoo(string))
}
}
fun box() = A().value() == "TESTFOOBAR"
@@ -0,0 +1,21 @@
package foo
trait Test {
fun addFoo(s:String) : String {
return s + "FOO"
}
}
trait ExtendedTest : Test {
fun hooray() : String {
return "hooray"
}
}
class A() : ExtendedTest {
fun eval() : String {
return addFoo(hooray());
}
}
fun box() = (A().eval() == "hoorayFOO")
@@ -0,0 +1,25 @@
package foo
trait A {
fun addFoo(s:String) : String {
return s + "FOO"
}
}
trait B {
fun hooray() : String {
return "hooray"
}
}
trait AD : A, B {
}
class Test() : AD {
fun eval() : String {
return addFoo(hooray());
}
}
fun box() = (Test().eval() == "hoorayFOO")