JS tests: fix testData files

This commit is contained in:
Zalim Bashorov
2014-09-30 23:18:48 +04:00
parent 9ac193407b
commit 5a63e34c19
18 changed files with 29 additions and 108 deletions
@@ -1,7 +1,5 @@
package foo
fun run<T>(f: () -> T) = f()
val r = "OK"
fun simple(s: String? = null): String {
@@ -1,7 +1,5 @@
package foo
fun run<T>(f: () -> T) = f()
fun funfun(): Boolean {
val result = true
@@ -1,7 +1,5 @@
package foo
fun run<T>(f: () -> T) = f()
class A {
val a = 12
var b = 1
@@ -1,7 +1,5 @@
package foo
fun run<T>(f: () -> T) = f()
fun box(): Boolean {
val t = run {
object {
@@ -1,7 +1,5 @@
package foo
fun run<T>(f: () -> T) = f()
fun box(): String {
fun simple(s: String? = null): String {
if (s != null) return s
@@ -1,7 +1,5 @@
package foo
fun run<T>(f: () -> T) = f()
class Foo {
val OK = "OK";
var result: String = ""
@@ -2,8 +2,6 @@
package foo
fun run<T>(f: Int.() -> T) = 1.f()
public class Foo(val trigger: () -> Any) {
fun test() = run {trigger()};
}
@@ -1,7 +1,5 @@
package foo
fun run<T>(f: ()->T) = f()
fun box(): String {
val t = run {
object {
@@ -38,46 +38,30 @@ fun box(): String {
// Check that same Dat's have the same hashcode.
val sameDs = listOf(Dat("a", "b"), Dat("a", "b"))
assertAllEqual(map(sameDs, hashCoder))
assertAllEqual(sameDs.map(hashCoder))
// Check that different Dat's have different hashcodes (at least some of them).
val differentDs = listOf(Dat("a", "b"), Dat("a", "c"), Dat("a", "d"))
assertSomeNotEqual(map(differentDs, hashCoder))
assertSomeNotEqual(differentDs.map(hashCoder))
// Check the same on Obj's, which should be always different and with different hashcodes.
val sameOs = listOf(Obj("a", "b"), Obj("a", "b"), Obj("a", "b"))
val differentOs = listOf(Obj("a", "b"), Obj("a", "b"), Obj("a", "b"))
// Obj's are always different.
assertSomeNotEqual(map(sameOs, hashCoder))
assertSomeNotEqual(map(differentOs, hashCoder))
assertSomeNotEqual(sameOs.map(hashCoder))
assertSomeNotEqual(differentOs.map(hashCoder))
// Both Dat's and Obj's wrapped as Holder should retain their hashcode relations.
val sameHDs = map(sameDs, wrapInH)
assertAllEqual(map(sameHDs, hashCoder))
val differentHDs = map(differentDs, wrapInH)
assertSomeNotEqual(map(differentHDs, hashCoder))
val sameHDs = sameDs.map(wrapInH)
assertAllEqual(sameHDs.map(hashCoder))
val differentHDs = differentDs.map(wrapInH)
assertSomeNotEqual(differentHDs.map(hashCoder))
val sameHOs = map(sameOs, wrapInH)
assertSomeNotEqual(map(sameHOs, hashCoder))
val differentHOs = map(differentOs, wrapInH)
assertSomeNotEqual(map(differentHOs, hashCoder))
val sameHOs = sameOs.map(wrapInH)
assertSomeNotEqual(sameHOs.map(hashCoder))
val differentHOs = differentOs.map(wrapInH)
assertSomeNotEqual(differentHOs.map(hashCoder))
return "OK"
}
fun listOf<T>(vararg a: T): List<T> {
val list = ArrayList<T>()
for (e in a) {
list.add(e)
}
return list
}
fun map<T, S>(c : Iterable<T>, transform : (T) -> S) : List<S> {
val list = ArrayList<S>()
for (t in c) {
list.add(transform(t))
}
return list
}
@@ -3,15 +3,15 @@ package foo
import java.util.*
fun box(): Boolean {
val data = arrayList("foo", "bar")
if (data.head != "foo") {
val data = myArrayList("foo", "bar")
if (data.myHead != "foo") {
return false
}
return true
}
public fun arrayList<T>(vararg values: T): ArrayList<T> {
inline public fun myArrayList<T>(vararg values: T): ArrayList<T> {
val c = ArrayList<T>()
for (v in values) {
c.add(v)
@@ -19,7 +19,7 @@ public fun arrayList<T>(vararg values: T): ArrayList<T> {
return c
}
public val <T> ArrayList<T>.head: T
inline public val <T> ArrayList<T>.myHead: T
get() {
return get(0)
}
@@ -1,9 +1,5 @@
package foo
// todo drop
class Pair<F, S>(val first: F, val second: S)
fun <F, S> F.to(second: S): Pair<F, S> = Pair(this, second)
fun box(): String {
val testInput = "test data\t1foo 2 bar"
val tests = array(
@@ -5,8 +5,6 @@
package foo
inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
inline fun Inline.calcExt(s: (Int) -> Int, p: Int) : Int {
return s(p)
}
@@ -33,6 +33,4 @@ public fun Input.copyTo(output: Output, size: Int): Int {
return output.doOutput(this.data())
}
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
public inline fun with2<T>(receiver : T, inlineOptions(ONLY_LOCAL_RETURN) body : T.() -> Unit) : Unit = {receiver.body()}()
@@ -2,18 +2,6 @@ package foo
import java.util.ArrayList;
// TODO: drop when arrayListOf will be available here.
fun arrayListOf<T>(vararg a: T): ArrayList<T> {
val list = ArrayList<T>();
for (e in a) {
list.add(e)
}
return list
}
fun box(): String {
val list = arrayListOf(3, "2", -1, null, 0, 8, 5, "3", 77, -15)
val subset = arrayListOf(3, "2", -1, null)
@@ -2,17 +2,6 @@ package foo
import java.util.ArrayList;
// TODO: drop when listOf will be available here.
fun listOf<T>(vararg a: T): List<T> {
val list = ArrayList<T>();
for (e in a) {
list.add(e)
}
return list
}
fun test<T>(list: List<T>, elements: List<T>, expected: List<Int>, method: List<T>.(T) -> Int, methodName: String): String? {
for (i in 0..elements.size() - 1) {
val actual = list.method(elements[i])
@@ -3,17 +3,6 @@ package foo
import java.util.ArrayList;
// TODO: drop when listOf will be available here.
fun listOf<T>(vararg a: T): List<T> {
val list = ArrayList<T>();
for (e in a) {
list.add(e)
}
return list
}
fun test<T>(a: List<T>, b: List<T>, removed: Boolean, expected: List<T>): String? {
val t = ArrayList<T>(a.size())
t.addAll(a)
@@ -2,18 +2,6 @@ package foo
import java.util.ArrayList;
// TODO: drop when listOf will be available here.
fun listOf<T>(vararg a: T): List<T> {
val list = ArrayList<T>();
for (e in a) {
list.add(e)
}
return list
}
fun test<T>(a: List<T>, b: List<T>, removed: Boolean, expected: List<T>): String? {
val t = ArrayList<T>(a.size())
t.addAll(a)
@@ -2,15 +2,22 @@ package foo
import java.util.*
fun <T> ArrayList<T>.plusAssign(other: Collection<T>) {
class A<T>(val list: MutableList<T>) {
fun addAll(c: Collection<T>) {
list.addAll(c)
}
}
fun <T> A<T>.plusAssign(other: Collection<T>) {
addAll(other)
}
fun box(): Boolean {
var v1 = ArrayList<String>()
val v2 = ArrayList<String>()
v1.add("foo")
v2.add("bar")
v1 += v2
var v1 = arrayListOf("foo")
val v2 = listOf("bar")
val a = A(v1)
a += v2
return (v1.size() == 2 && v1[0] == "foo" && v1[1] == "bar")
}