diff --git a/java/ql/test/kotlin/query-tests/ConstantLoopCondition/A.kt b/java/ql/test/kotlin/query-tests/ConstantLoopCondition/A.kt new file mode 100644 index 00000000000..8c111c58fe7 --- /dev/null +++ b/java/ql/test/kotlin/query-tests/ConstantLoopCondition/A.kt @@ -0,0 +1,24 @@ +fun fn0(f: Function0) = f() + +fun fn1() { + var c = true + while (c) { // TODO: false positive + fn0 { + c = false + } + } + + var d = true + while (d) { + fn0 { + println(d) + } + } + + val e = true + while (e) { + fn0 { + println(e) + } + } +} diff --git a/java/ql/test/kotlin/query-tests/ConstantLoopCondition/ConstantLoopCondition.expected b/java/ql/test/kotlin/query-tests/ConstantLoopCondition/ConstantLoopCondition.expected new file mode 100644 index 00000000000..7c8765b1933 --- /dev/null +++ b/java/ql/test/kotlin/query-tests/ConstantLoopCondition/ConstantLoopCondition.expected @@ -0,0 +1,3 @@ +| A.kt:5:12:5:12 | c | $@ might not terminate, as this loop condition is constant within the loop. | A.kt:5:5:9:5 | while (...) | Loop | +| A.kt:12:12:12:12 | d | $@ might not terminate, as this loop condition is constant within the loop. | A.kt:12:5:16:5 | while (...) | Loop | +| A.kt:19:12:19:12 | e | $@ might not terminate, as this loop condition is constant within the loop. | A.kt:19:5:23:5 | while (...) | Loop | diff --git a/java/ql/test/kotlin/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref b/java/ql/test/kotlin/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref new file mode 100644 index 00000000000..37e6a9b72fe --- /dev/null +++ b/java/ql/test/kotlin/query-tests/ConstantLoopCondition/ConstantLoopCondition.qlref @@ -0,0 +1 @@ +Likely Bugs/Termination/ConstantLoopCondition.ql