mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add tests for break in loops
This commit is contained in:
+20
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user