Int#downto
This commit is contained in:
@@ -48,4 +48,8 @@ public final class RangeTest extends SingleFileTranslationTest {
|
||||
public void testIntUpTo() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testIntDownTo() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -31,5 +31,6 @@ public final class RangesFIF extends CompositeFIF {
|
||||
|
||||
private RangesFIF() {
|
||||
add(pattern("Int.upto"), new CallStandardMethodIntrinsic("Kotlin.intUpto", true, 1));
|
||||
add(pattern("Int.downto"), new CallStandardMethodIntrinsic("Kotlin.intDownto", true, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,11 @@ var kotlin = {set:function (receiver, key, value) {
|
||||
};
|
||||
|
||||
Kotlin.intUpto = function (from, limit) {
|
||||
return Kotlin.$new(Kotlin.NumberRange)(from, limit - from + 1);
|
||||
return Kotlin.$new(Kotlin.NumberRange)(from, limit - from + 1, false);
|
||||
};
|
||||
|
||||
Kotlin.intDownto = function (from, limit) {
|
||||
return Kotlin.$new(Kotlin.NumberRange)(from, from - limit + 1, true);
|
||||
};
|
||||
|
||||
Kotlin.modules = {};
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package foo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box() : Boolean {
|
||||
var elems = ArrayList<Int>()
|
||||
for (i in 4 downto 0) {
|
||||
elems.add(i)
|
||||
}
|
||||
return elems[0] == 4 && elems[1] == 3 && elems[2] == 2 && elems[3] == 1 && elems[4] == 0
|
||||
}
|
||||
Reference in New Issue
Block a user