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
@@ -0,0 +1,11 @@
|
||||
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val s = Array<String>(1, { "" })
|
||||
s[1, -1] = "O"
|
||||
s[2, -2] += "K"
|
||||
return s[-3, 3]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val s = Array<String>(1, { "" })
|
||||
s[1, -1] = "OK"
|
||||
return s[-2, 2]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
val s = IntArray(1)
|
||||
s[0] = 5
|
||||
s[0] += 7
|
||||
return if (s[0] == 12) "OK" else "Fail ${s[0]}"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
fun ArrayList<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun ArrayList<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val s = ArrayList<String>(1)
|
||||
s.add("")
|
||||
s[1, -1] = "O"
|
||||
s[2, -2] += "K"
|
||||
return s[2, -2]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
fun ArrayList<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun ArrayList<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val s = ArrayList<String>(1)
|
||||
s.add("")
|
||||
s[1, -1] = "OK"
|
||||
return s[2, -2]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in BooleanArray(5)) {
|
||||
if (x != false) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in ByteArray(5)) {
|
||||
if (x != 0.toByte()) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in CharArray(5)) {
|
||||
if (x != 0.toChar()) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in DoubleArray(5)) {
|
||||
if (x != 0.toDouble()) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in FloatArray(5)) {
|
||||
if (x != 0.toFloat()) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in IntArray(5)) {
|
||||
if (x != 0) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in LongArray(5)) {
|
||||
if (x != 0.toLong()) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
for (x in ShortArray(5)) {
|
||||
if (x != 0.toShort()) return "Fail $x"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.util.HashMap
|
||||
|
||||
fun HashMap<String, Int?>.set(index: String, elem: Int?) {
|
||||
this.put(index, elem)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val s = HashMap<String, Int?>()
|
||||
s["239"] = 239
|
||||
return if (s["239"] == 239) "OK" else "Fail"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun box(): String {
|
||||
val a = Array<Int>(5, {it})
|
||||
val x = a.indices.iterator()
|
||||
while (x.hasNext()) {
|
||||
val i = x.next()
|
||||
if (a[i] != i) return "Fail $i ${a[i]}"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun box(): String {
|
||||
val a = CharArray(5)
|
||||
val x = a.indices.iterator()
|
||||
while (x.hasNext()) {
|
||||
val i = x.next()
|
||||
if (a[i] != 0.toChar()) return "Fail $i ${a[i]}"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun box(): String {
|
||||
val x = Array<Int>(5, { it } ).iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (x.next() != i) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = BooleanArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = ByteArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = ByteArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.nextByte()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = CharArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = DoubleArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = FloatArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = IntArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = LongArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = LongArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.nextLong()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun box(): String {
|
||||
val a = ShortArray(5)
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem }
|
||||
fun IntArray.get(index: Long) = this[index.toInt()]
|
||||
|
||||
fun box(): String {
|
||||
var l = IntArray(1)
|
||||
l[0.toLong()] = 4
|
||||
l[0.toLong()] += 6
|
||||
return if (l[0.toLong()] == 10) "OK" else "Fail"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class A() {
|
||||
class B(val i: Int) {
|
||||
}
|
||||
|
||||
fun test() = Array<B> (10, { B(it) })
|
||||
}
|
||||
|
||||
fun box() = if(A().test()[5].i == 5) "OK" else "fail"
|
||||
Reference in New Issue
Block a user