KT-925 step methods for integral ranges

This commit is contained in:
Alex Tkachman
2012-01-06 13:11:44 +02:00
parent 4627738ca4
commit 1d2e237312
13 changed files with 467 additions and 55 deletions
@@ -0,0 +1,54 @@
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.byt..10.byt
var s1 = 0
for(e in r1 step 2) {
s1 += e
}
return s1 == 25
}
fun test3() : Boolean {
val r1 = 1.byt..10.lng
var s1 = 0.lng
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.lng
}
fun test4() : Boolean {
val r1 = 1.byt..10.sht
var s1 = 0.sht
for(e in r1 step 2) {
s1 += e
}
return s1 == 25.sht
}
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"
}