Add BE tests for 'break' and 'continue' inside 'when'
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
// !LANGUAGE: +AllowBreakAndContinueInsideWhen
|
||||||
|
|
||||||
|
fun testFor() {
|
||||||
|
val xs = IntArray(10) { i -> i }
|
||||||
|
var k = 0
|
||||||
|
for (x in xs) {
|
||||||
|
when {
|
||||||
|
k > 2 -> break
|
||||||
|
}
|
||||||
|
++k
|
||||||
|
}
|
||||||
|
if (k != 3) throw AssertionError()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testWhile() {
|
||||||
|
var k = 0
|
||||||
|
while (k < 10) {
|
||||||
|
when {
|
||||||
|
k > 2 -> break
|
||||||
|
}
|
||||||
|
++k
|
||||||
|
}
|
||||||
|
if (k != 3) throw AssertionError()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testDoWhile() {
|
||||||
|
var k = 0
|
||||||
|
do {
|
||||||
|
when {
|
||||||
|
k > 2 -> break
|
||||||
|
}
|
||||||
|
++k
|
||||||
|
} while (k < 10)
|
||||||
|
if (k != 3) throw AssertionError()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
testFor()
|
||||||
|
testWhile()
|
||||||
|
testDoWhile()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
// !LANGUAGE: +AllowBreakAndContinueInsideWhen
|
||||||
|
|
||||||
|
fun testFor() {
|
||||||
|
val xs = IntArray(10) { i -> i }
|
||||||
|
var k = 0
|
||||||
|
var s = ""
|
||||||
|
for (x in xs) {
|
||||||
|
++k
|
||||||
|
when {
|
||||||
|
k > 2 -> continue
|
||||||
|
}
|
||||||
|
s += "$k;"
|
||||||
|
}
|
||||||
|
if (s != "1;2;") throw AssertionError(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testWhile() {
|
||||||
|
var k = 0
|
||||||
|
var s = ""
|
||||||
|
while (k < 10) {
|
||||||
|
++k
|
||||||
|
when {
|
||||||
|
k > 2 -> continue
|
||||||
|
}
|
||||||
|
s += "$k;"
|
||||||
|
}
|
||||||
|
if (s != "1;2;") throw AssertionError(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testDoWhile() {
|
||||||
|
var k = 0
|
||||||
|
var s = ""
|
||||||
|
do {
|
||||||
|
++k
|
||||||
|
when {
|
||||||
|
k > 2 -> continue
|
||||||
|
}
|
||||||
|
s += "$k;"
|
||||||
|
} while (k < 10)
|
||||||
|
if (s != "1;2;") throw AssertionError(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
testFor()
|
||||||
|
testWhile()
|
||||||
|
testDoWhile()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+10
@@ -4683,6 +4683,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("breakInWhen.kt")
|
||||||
|
public void testBreakInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/breakInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compareBoxedIntegerToZero.kt")
|
@TestMetadata("compareBoxedIntegerToZero.kt")
|
||||||
public void testCompareBoxedIntegerToZero() throws Exception {
|
public void testCompareBoxedIntegerToZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
||||||
@@ -4708,6 +4713,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("continueInWhen.kt")
|
||||||
|
public void testContinueInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("continueInWhile.kt")
|
@TestMetadata("continueInWhile.kt")
|
||||||
public void testContinueInWhile() throws Exception {
|
public void testContinueInWhile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
||||||
|
|||||||
+10
@@ -4683,6 +4683,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("breakInWhen.kt")
|
||||||
|
public void testBreakInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/breakInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compareBoxedIntegerToZero.kt")
|
@TestMetadata("compareBoxedIntegerToZero.kt")
|
||||||
public void testCompareBoxedIntegerToZero() throws Exception {
|
public void testCompareBoxedIntegerToZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
||||||
@@ -4708,6 +4713,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("continueInWhen.kt")
|
||||||
|
public void testContinueInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("continueInWhile.kt")
|
@TestMetadata("continueInWhile.kt")
|
||||||
public void testContinueInWhile() throws Exception {
|
public void testContinueInWhile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
||||||
|
|||||||
+10
@@ -4653,6 +4653,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("breakInWhen.kt")
|
||||||
|
public void testBreakInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/breakInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compareBoxedIntegerToZero.kt")
|
@TestMetadata("compareBoxedIntegerToZero.kt")
|
||||||
public void testCompareBoxedIntegerToZero() throws Exception {
|
public void testCompareBoxedIntegerToZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
||||||
@@ -4678,6 +4683,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("continueInWhen.kt")
|
||||||
|
public void testContinueInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("continueInWhile.kt")
|
@TestMetadata("continueInWhile.kt")
|
||||||
public void testContinueInWhile() throws Exception {
|
public void testContinueInWhile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
||||||
|
|||||||
Generated
+10
@@ -3808,6 +3808,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("breakInWhen.kt")
|
||||||
|
public void testBreakInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/breakInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compareBoxedIntegerToZero.kt")
|
@TestMetadata("compareBoxedIntegerToZero.kt")
|
||||||
public void testCompareBoxedIntegerToZero() throws Exception {
|
public void testCompareBoxedIntegerToZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
||||||
@@ -3833,6 +3838,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("continueInWhen.kt")
|
||||||
|
public void testContinueInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("continueInWhile.kt")
|
@TestMetadata("continueInWhile.kt")
|
||||||
public void testContinueInWhile() throws Exception {
|
public void testContinueInWhile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
||||||
|
|||||||
+10
@@ -3818,6 +3818,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/breakInFinally.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("breakInWhen.kt")
|
||||||
|
public void testBreakInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/breakInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compareBoxedIntegerToZero.kt")
|
@TestMetadata("compareBoxedIntegerToZero.kt")
|
||||||
public void testCompareBoxedIntegerToZero() throws Exception {
|
public void testCompareBoxedIntegerToZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/compareBoxedIntegerToZero.kt");
|
||||||
@@ -3843,6 +3848,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInForCondition.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("continueInWhen.kt")
|
||||||
|
public void testContinueInWhen() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("continueInWhile.kt")
|
@TestMetadata("continueInWhile.kt")
|
||||||
public void testContinueInWhile() throws Exception {
|
public void testContinueInWhile() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/continueInWhile.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user