Skip to content

Commit b148494

Browse files
kotlin tests: sync dataflow/foreach test inputs and K2 expected output
Copy K1's richer C2.kt (which includes test2, test3 and l.get(0) in test) into test-kotlin2. K2 in -language 2.0 mode already tracks dataflow through array.set() and indirect wrapper calls, so the additional tests produce results identical to K1. The expected files for test-kotlin1 and test-kotlin2 are now byte-identical for this test. Verified: - test-kotlin1 (kotlinc 2.3.20 / -language 1.9): all tests pass - test-kotlin2 (kotlinc 2.4.0 / -language 2.0): all tests pass Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a092263 commit b148494

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

java/ql/test-kotlin2/library-tests/dataflow/foreach/C2.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,33 @@ class C2 {
88
val l = arrayOf(taint("a"), "")
99
sink(l)
1010
sink(l[0])
11+
sink(l.get(0))
1112
for (i in l.indices) {
1213
sink(l[i])
1314
}
1415
for (s in l) {
1516
sink(s)
1617
}
1718
}
19+
20+
fun test2() {
21+
val l1 = arrayOf("")
22+
val l2 = arrayOf("")
23+
l1[0] = taint("a")
24+
l2.set(0, taint("a"))
25+
sink(l1[0])
26+
sink(l2[0])
27+
sink(l1.get(0))
28+
sink(l2.get(0))
29+
}
30+
31+
fun setWrapper(l: Array<String>, v: String) {
32+
l.set(0, v)
33+
}
34+
fun test3() {
35+
val l = arrayOf("")
36+
setWrapper(l, taint("a"))
37+
sink(l[0])
38+
sink(l.get(0))
39+
}
1840
}

java/ql/test-kotlin2/library-tests/dataflow/foreach/test.expected

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@
44
| C1.java:10:44:10:46 | "a" | C1.java:19:20:19:20 | s |
55
| C2.kt:8:31:8:33 | "a" | C2.kt:9:14:9:14 | l |
66
| C2.kt:8:31:8:33 | "a" | C2.kt:10:14:10:17 | ...[...] |
7-
| C2.kt:8:31:8:33 | "a" | C2.kt:12:18:12:21 | ...[...] |
8-
| C2.kt:8:31:8:33 | "a" | C2.kt:15:18:15:18 | s |
7+
| C2.kt:8:31:8:33 | "a" | C2.kt:11:14:11:21 | get(...) |
8+
| C2.kt:8:31:8:33 | "a" | C2.kt:13:18:13:21 | ...[...] |
9+
| C2.kt:8:31:8:33 | "a" | C2.kt:16:18:16:18 | s |
10+
| C2.kt:23:23:23:25 | "a" | C2.kt:25:14:25:18 | ...[...] |
11+
| C2.kt:23:23:23:25 | "a" | C2.kt:27:14:27:22 | get(...) |
12+
| C2.kt:24:25:24:27 | "a" | C2.kt:26:14:26:18 | ...[...] |
13+
| C2.kt:24:25:24:27 | "a" | C2.kt:28:14:28:22 | get(...) |
14+
| C2.kt:36:29:36:31 | "a" | C2.kt:37:14:37:17 | ...[...] |
15+
| C2.kt:36:29:36:31 | "a" | C2.kt:38:14:38:21 | get(...) |

0 commit comments

Comments
 (0)