KT-8005 Add test to prove the issue is no more reproducible

This commit is contained in:
Alexey Andreev
2016-05-11 11:37:34 +03:00
parent 3cd7dcdb26
commit 4387c31939
2 changed files with 30 additions and 0 deletions
@@ -268,4 +268,10 @@ public class InlineEvaluationOrderTestGenerated extends AbstractInlineEvaluation
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/inlineEvaluationOrder/cases/whileComplex.kt");
doTest(fileName);
}
@TestMetadata("whileConditionExtracted.kt")
public void testWhileConditionExtracted() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/inlineEvaluationOrder/cases/whileConditionExtracted.kt");
doTest(fileName);
}
}
@@ -0,0 +1,24 @@
// See KT-8005
package foo
private inline fun bar(predicate: (Char) -> Boolean): Int {
var i = 0
val str = "abc "
while (predicate(str[i]) && i < 3) {
i++
}
return i
}
private fun test(c: Char): Int {
return bar { it != c }
}
fun box(): String {
assertEquals(0, test('a'))
assertEquals(1, test('b'))
assertEquals(2, test('c'))
assertEquals(3, test('*'))
return "OK"
}