Refactor codegen tests
- initialize environment only once in setUp() - add comments on why some tests are disabled - modify and rename some tests - re-enable now working tests - extract some tests into files with box() - remove useless 'throws' declarations and commented code
This commit is contained in:
committed by
Alexander Udalov
parent
99827d10a8
commit
0df71bd696
@@ -6,4 +6,13 @@ fun test(a : A) {
|
||||
if (a.method != null) {
|
||||
a.method!!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override val method = { }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(B())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -6,4 +6,13 @@ fun test(a : A) {
|
||||
if (a.method != null) {
|
||||
a.method!!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override val method = { }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(B())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -12,15 +12,14 @@ fun t2() : Boolean {
|
||||
|
||||
fun t3() {
|
||||
val d: D = D("s")
|
||||
System.out?.println(d?.s)
|
||||
System.out?.println(d?.s == "s") //prints true
|
||||
System.out?.println(d) //ok
|
||||
val x = d?.s
|
||||
if (!(d?.s == "s")) throw AssertionError()
|
||||
}
|
||||
|
||||
fun t4() {
|
||||
val e: E? = E()
|
||||
System.out?.println(e?.bar() == e) //verify error
|
||||
System.out?.println(e?.foo()) //verify error
|
||||
if (!(e?.bar() == e)) throw AssertionError()
|
||||
val x = e?.foo()
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import java.util.LinkedList
|
||||
import java.util.ArrayList
|
||||
|
||||
open class BaseStringList: LinkedList<String>() {
|
||||
open class BaseStringList: ArrayList<String>() {
|
||||
}
|
||||
|
||||
class StringList: BaseStringList() {
|
||||
@@ -14,6 +14,6 @@ fun box(): String {
|
||||
myStringList.add("first element")
|
||||
if (myStringList.get(0) != "StringList.get()") return "Fail #1"
|
||||
if ((myStringList: BaseStringList).get(0) != "StringList.get()") return "Fail #2"
|
||||
if ((myStringList: LinkedList<String>).get(0) != "StringList.get()") return "Fail #3"
|
||||
if ((myStringList: ArrayList<String>).get(0) != "StringList.get()") return "Fail #3"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package test
|
||||
|
||||
class List<T>(len: Int, cls : java.lang.Class) {
|
||||
val a : Array<T?> = Array<T?>(len)
|
||||
class List<T>(len: Int) {
|
||||
val a = Array<T?>(len) { null }
|
||||
|
||||
fun reverse() {
|
||||
var i = 0
|
||||
@@ -17,19 +15,19 @@ class List<T>(len: Int, cls : java.lang.Class) {
|
||||
fun box() : String {
|
||||
val d = List<Int>(1)
|
||||
d.a[0] = 10
|
||||
println(d.a[0])
|
||||
checkEquals(d.a[0], 10)
|
||||
|
||||
val a = List<String>(1)
|
||||
a.a[0] = "1"
|
||||
println(a.a[0])
|
||||
checkEquals(a.a[0], "1")
|
||||
|
||||
val b = List<Int?>(1)
|
||||
b.a[0] = 10
|
||||
println(b.a[0])
|
||||
checkEquals(b.a[0], 10)
|
||||
|
||||
val c = List<Array<Int>>(1)
|
||||
c.a[0] = Array<Int>(4,{-1})
|
||||
println(c.a[0]?.size)
|
||||
checkEquals(c.a[0]?.size, 4)
|
||||
|
||||
val e = List<Int>(5)
|
||||
e.a[0] = 0
|
||||
@@ -38,12 +36,16 @@ fun box() : String {
|
||||
e.a[3] = 3
|
||||
e.a[4] = 4
|
||||
e.reverse()
|
||||
for(el in e.a)
|
||||
println(el)
|
||||
for (i in 0..4)
|
||||
checkEquals(e.a[i], 4-i)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun println(s : Any?) {
|
||||
System.out?.println(s);
|
||||
fun checkEquals(a: Any?, b: Any?) {
|
||||
if (a != b) throw AssertionError("Expected: $b, actual: $a")
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(box())
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ fun box() : String {
|
||||
for (i in vals.indices)
|
||||
for (j in i..vals.lastIndex())
|
||||
diffs.add(vals[i] - vals[j])
|
||||
System.out?.println(diffs.size())
|
||||
val size = diffs.size()
|
||||
|
||||
if (size != 8) return "Fail $size"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import java.util.*
|
||||
|
||||
class Template() {
|
||||
val collected = LinkedList<String>()
|
||||
val collected = ArrayList<String>()
|
||||
|
||||
fun String.plus() {
|
||||
collected.add(this@plus)
|
||||
|
||||
Reference in New Issue
Block a user