Add tests for break in loops

This commit is contained in:
Vitaliy.Bibaev
2017-09-18 19:49:57 +03:00
parent 359d1145a0
commit 50588a4e7f
5 changed files with 40 additions and 0 deletions
@@ -144,6 +144,26 @@ abstract class DslTestCase(private val directoryName: String, private val dsl: D
}
}
fun testLoopWithBreak() {
doTest {
val objects = declare(variable(types.listOfAny, "objects"), +"getObjects()", false)
forEachLoop(variable(types.anyType, "object"), objects) {
breakIteration()
}
}
}
fun testLoopWithNestedBreak() {
doTest {
val objects = declare(variable(types.listOfAny, "objects"), +"getObjects()", false)
forEachLoop(variable(types.anyType, "object"), objects) {
ifBranch(loopVariable.property("isEmpty")) {
+breakIteration()
}
}
}
}
fun testLambdaWithExpression() {
doTest {
+lambda("x") {
@@ -0,0 +1,4 @@
final java.util.List<java.lang.Object> objects = getObjects();
for (java.lang.Object object : objects) {
break;
}
@@ -0,0 +1,6 @@
final java.util.List<java.lang.Object> objects = getObjects();
for (java.lang.Object object : objects) {
if(object.isEmpty) {
break;
}
}
@@ -0,0 +1,4 @@
var objects: kotlin.collections.List<kotlin.Any> = getObjects()
for (object in objects) {
break
}
@@ -0,0 +1,6 @@
var objects: kotlin.collections.List<kotlin.Any> = getObjects()
for (object in objects) {
if (object.isEmpty) {
break
}
}