Minor: added regression tests for downTo.
Adopted tests from patch attached to KT-2586.
This commit is contained in:
@@ -53,4 +53,8 @@ public final class RangeTest extends SingleFileTranslationTest {
|
|||||||
public void testRangeEquals() throws Exception {
|
public void testRangeEquals() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testIntDownTo() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
fun testDownTo() {
|
||||||
|
var elems = ArrayList<Int>()
|
||||||
|
for (i in 4 downTo 0) {
|
||||||
|
elems.add(i)
|
||||||
|
}
|
||||||
|
assertTrue(elems[0] == 4 && elems[1] == 3 && elems[2] == 2 && elems[3] == 1 && elems[4] == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testDownToDoesNotIterate() {
|
||||||
|
for (i in 0 downTo 1) {
|
||||||
|
fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
testDownTo()
|
||||||
|
testDownToDoesNotIterate()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user