added tests to DataFlowTest
to be able to compare difference in the next commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
== foo ==
|
||||||
|
fun foo() {
|
||||||
|
val b: Boolean
|
||||||
|
if (1 < 2) {
|
||||||
|
b = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b = true
|
||||||
|
}
|
||||||
|
use(b)
|
||||||
|
}
|
||||||
|
---------------------
|
||||||
|
L0:
|
||||||
|
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
||||||
|
2 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) })
|
||||||
|
v(val b: Boolean) INIT: in: {} out: {b=D}
|
||||||
|
mark(if (1 < 2) { b = false } else { b = true }) INIT: in: {b=D} out: {b=D}
|
||||||
|
mark(1 < 2)
|
||||||
|
r(1)
|
||||||
|
r(2)
|
||||||
|
call(<, compareTo)
|
||||||
|
jf(L2)
|
||||||
|
3 mark({ b = false })
|
||||||
|
r(false) USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
w(b) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
2 jmp(L3) INIT: in: {b=ID} out: {b=ID} USE: in: {b=READ} out: {b=READ}
|
||||||
|
L2:
|
||||||
|
3 mark({ b = true }) INIT: in: {b=D} out: {b=D}
|
||||||
|
r(true) USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
w(b) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
L3:
|
||||||
|
2 mark(use(b)) INIT: in: {b=ID} out: {b=ID}
|
||||||
|
error(use, No resolved call) USE: in: {b=READ} out: {b=READ}
|
||||||
|
r(b) USE: in: {} out: {b=READ}
|
||||||
|
error(use, No resolved call)
|
||||||
|
L1:
|
||||||
|
1 <END> INIT: in: {} out: {}
|
||||||
|
error:
|
||||||
|
<ERROR>
|
||||||
|
sink:
|
||||||
|
<SINK> USE: in: {} out: {}
|
||||||
|
=====================
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fun foo() {
|
||||||
|
val b: Boolean
|
||||||
|
if (1 < 2) {
|
||||||
|
b = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b = true
|
||||||
|
}
|
||||||
|
use(b)
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
== foo ==
|
||||||
|
fun foo(numbers: Collection<Int>) {
|
||||||
|
for (i in numbers) {
|
||||||
|
val b: Boolean
|
||||||
|
if (1 < 2) {
|
||||||
|
b = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b = true
|
||||||
|
}
|
||||||
|
use(b)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
---------------------
|
||||||
|
L0:
|
||||||
|
1 <START> INIT: in: {} out: {}
|
||||||
|
v(numbers: Collection<Int>) INIT: in: {} out: {numbers=D}
|
||||||
|
w(numbers) INIT: in: {numbers=D} out: {numbers=ID}
|
||||||
|
2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {numbers=ID} out: {numbers=ID}
|
||||||
|
3 mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) USE: in: {numbers=READ} out: {numbers=READ}
|
||||||
|
r(numbers) USE: in: {} out: {numbers=READ}
|
||||||
|
v(i) INIT: in: {numbers=ID} out: {i=D, numbers=ID}
|
||||||
|
w(i) INIT: in: {i=D, numbers=ID} out: {i=ID, numbers=ID}
|
||||||
|
L3:
|
||||||
|
jmp?(L2) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID} USE: in: {} out: {}
|
||||||
|
L4 [loop entry point]:
|
||||||
|
L5 [body entry point]:
|
||||||
|
4 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID}
|
||||||
|
v(val b: Boolean)
|
||||||
|
mark(if (1 < 2) { b = false } else { b = true })
|
||||||
|
mark(1 < 2)
|
||||||
|
r(1)
|
||||||
|
r(2)
|
||||||
|
call(<, compareTo)
|
||||||
|
jf(L6)
|
||||||
|
5 mark({ b = false })
|
||||||
|
r(false) USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
w(b) USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
4 jmp(L7) USE: in: {b=READ} out: {b=READ}
|
||||||
|
L6:
|
||||||
|
5 mark({ b = true })
|
||||||
|
r(true) USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
w(b) USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
L7:
|
||||||
|
4 mark(use(b)) USE: in: {b=READ} out: {b=READ}
|
||||||
|
r(b) USE: in: {b=WRITTEN_AFTER_READ} out: {b=READ}
|
||||||
|
call(use, use)
|
||||||
|
jmp(L4 [loop entry point]) USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
|
- 3 jmp?(L4 [loop entry point])
|
||||||
|
L2:
|
||||||
|
read (Unit) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID}
|
||||||
|
L1:
|
||||||
|
1 <END> INIT: in: {numbers=ID} out: {numbers=ID}
|
||||||
|
error:
|
||||||
|
<ERROR> INIT: in: {} out: {}
|
||||||
|
sink:
|
||||||
|
<SINK> INIT: in: {numbers=ID} out: {numbers=ID} USE: in: {} out: {}
|
||||||
|
=====================
|
||||||
|
== use ==
|
||||||
|
fun use(vararg a: Any?) = a
|
||||||
|
---------------------
|
||||||
|
L0:
|
||||||
|
1 <START> INIT: in: {} out: {}
|
||||||
|
v(vararg a: Any?) INIT: in: {} out: {a=D}
|
||||||
|
w(a) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ}
|
||||||
|
r(a) INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ}
|
||||||
|
L1:
|
||||||
|
<END>
|
||||||
|
error:
|
||||||
|
<ERROR> INIT: in: {} out: {}
|
||||||
|
sink:
|
||||||
|
<SINK> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {}
|
||||||
|
=====================
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
fun foo(numbers: Collection<Int>) {
|
||||||
|
for (i in numbers) {
|
||||||
|
val b: Boolean
|
||||||
|
if (1 < 2) {
|
||||||
|
b = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b = true
|
||||||
|
}
|
||||||
|
use(b)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun use(vararg a: Any?) = a
|
||||||
@@ -58,6 +58,16 @@ public class DataFlowTestGenerated extends AbstractDataFlowTest {
|
|||||||
doTest("compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.kt");
|
doTest("compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("varInitializationInIf.kt")
|
||||||
|
public void testVarInitializationInIf() throws Exception {
|
||||||
|
doTest("compiler/testData/cfg-variables/basic/varInitializationInIf.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("varInitializationInIfInCycle.kt")
|
||||||
|
public void testVarInitializationInIfInCycle() throws Exception {
|
||||||
|
doTest("compiler/testData/cfg-variables/basic/varInitializationInIfInCycle.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("VariablesInitialization.kt")
|
@TestMetadata("VariablesInitialization.kt")
|
||||||
public void testVariablesInitialization() throws Exception {
|
public void testVariablesInitialization() throws Exception {
|
||||||
doTest("compiler/testData/cfg-variables/basic/VariablesInitialization.kt");
|
doTest("compiler/testData/cfg-variables/basic/VariablesInitialization.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user