Removed old range test which were spread all over the place.

This commit is contained in:
Evgeny Gerashchenko
2013-01-30 16:03:22 +04:00
parent 9c83a2f85f
commit 21c37951d6
11 changed files with 2 additions and 329 deletions
@@ -1,11 +0,0 @@
fun box() : String {
var cnt = 0
for (len in 4 downTo 1) {
cnt++
}
for (n in (1..5).reversed())
cnt++
return if(cnt == 9) "OK" else cnt.toString()
}
@@ -1,13 +0,0 @@
fun box() : String {
System.out?.println(System.out?.println(10.toFloat()..11.toFloat()))
for(f in 10.toFloat()..11.toFloat() step 0.3.toFloat()) {
System.out?.println(f)
}
for(f in 10.toDouble()..11.toDouble() step 0.3.toDouble()) {
System.out?.println(f)
}
return "OK"
}
@@ -1,54 +0,0 @@
fun test1() : Boolean {
val r1 = 1..10
var s1 = 0
for(e in r1 step 2) {
s1 += e
}
return s1 == 25
}
fun test2() : Boolean {
val r1 = 1.toByte()..10.toByte()
var s1 = 0
for(e in r1 step 2) {
s1 += e
}
return s1 == 25
}
fun test3() : Boolean {
val r1 = 1.toByte()..10.toLong()
var s1 = 0.toLong()
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.toLong()
}
fun test4() : Boolean {
val r1 = 1.toByte()..10.toShort()
var s1 = 0.toShort()
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.toShort()
}
fun test5() : Boolean {
val r1 = 'a'..'h'
var s1 = 0
for(e in r1 step 2) {
s1 ++
}
return s1 == 4
}
fun box() : String {
if(test1().not()) return "test1 failed"
if(test2().not()) return "test2 failed"
if(test3().not()) return "test3 failed"
if(test4().not()) return "test4 failed"
if(test5().not()) return "test4 failed"
return "OK"
}
@@ -1,100 +0,0 @@
fun testInt () : String {
val r1 = 1 rangeTo 4
if (r1.start != 1 || r1.end != 4) return "int rangeTo fail"
val r2 = 4 rangeTo 1
if (r2.start != 4 || r2.end != 1) return "int negative rangeTo fail"
val r3 = 5 downTo 0
if (r3.start != 5 || r3.end != 0 || r3.increment != -1) return "int downTo fail"
val r4 = 5 downTo 6
if (r4.start != 5 || r4.end != 6 || r4.increment != -1) return "int negative downTo fail"
return "OK"
}
fun testByte () : String {
val r1 = 1.toByte() rangeTo 4.toByte()
if (r1.start != 1.toByte() || r1.end != 4.toByte()) return "byte rangeTo fail"
val r2 = 4.toByte() rangeTo 1.toByte()
if (r2.start != 4.toByte() || r2.end != 1.toByte()) return "byte negative rangeTo fail"
val r3 = 5.toByte() downTo 0.toByte()
if (r3.start != 5.toByte() || r3.end != 0.toByte() || r3.increment != -1) return "byte downTo fail"
val r4 = 5.toByte() downTo 6.toByte()
if (r3.start != 5.toByte() || r3.end != 0.toByte() || r4.increment != -1) return "byte negative downTo fail"
return "OK"
}
fun testShort () : String {
val r1 = 1.toShort() rangeTo 4.toShort()
if (r1.start != 1.toShort() || r1.end != 4.toShort()) return "short rangeTo fail"
val r2 = 4.toShort() rangeTo 1.toShort()
if (r2.start != 4.toShort() || r2.end != 1.toShort()) return "short negative rangeTo fail"
val r3 = 5.toShort() downTo 0.toShort()
if (r3.start != 5.toShort() || r3.end != 0.toShort() || r3.increment != -1) return "short downTo fail"
val r4 = 5.toShort() downTo 6.toShort()
if (r3.start != 5.toShort() || r3.end != 0.toShort() || r4.increment != -1) return "short negative downTo fail"
return "OK"
}
fun testLong () : String {
val r1 = 1.toLong() rangeTo 4.toLong()
if (r1.start != 1.toLong() || r1.end != 4.toLong()) return "long rangeTo fail"
val r2 = 4.toLong() rangeTo 1.toLong()
if (r2.start != 4.toLong() || r2.end != 1.toLong()) return "long negative rangeTo fail"
val r3 = 5.toLong() downTo 0.toLong()
if (r3.start != 5.toLong() || r3.end != 0.toLong() || r3.increment != -1.toLong()) return "long downTo fail"
val r4 = 5.toLong() downTo 6.toLong()
if (r3.start != 5.toLong() || r3.end != 0.toLong() || r4.increment != -1.toLong()) return "long negative downTo fail"
return "OK"
}
fun testChar () : String {
val r1 = 'a' rangeTo 'd'
if (r1.start != 'a' || r1.end != 'd') return "char rangeTo fail"
val r2 = 'd' rangeTo 'a'
if(r2.start != 'd' || r2.end != 'a') return "char negative long fail"
val r3 = 'd' downTo 'a'
if (r3.start != 'd' || r3.end != 'a' || r3.increment != -1) return "char downTo fail"
val r4 = 'a' downTo 'd'
if (r4.start != 'a' || r4.end != 'd' || r4.increment != -1) return "char negative downTo fail"
return "OK"
}
fun box() : String {
var r : String
r = testInt()
if(r != "OK") return r
r = testByte()
if(r != "OK") return r
r = testShort()
if(r != "OK") return r
r = testLong()
if(r != "OK") return r
return "OK"
}