1
1
package org.usvm.samples.checkers
2
2
3
- import org.jacodb.ets.model.EtsScene
4
- import org.jacodb.ets.utils.loadEtsFileAutoConvert
3
+ import org.jacodb.ets.utils.loadEtsProjectFromIR
5
4
import org.junit.jupiter.api.Test
6
5
import org.usvm.UMachineOptions
7
6
import org.usvm.api.checkers.UnreachableCodeDetector
@@ -12,21 +11,27 @@ import org.usvm.util.getResourcePath
12
11
class UnreachableCodeDetectorTest {
13
12
@Test
14
13
fun testUnreachableCode () {
15
- val scene = run {
16
- val name = " UnreachableCode.ts"
17
- val path = getResourcePath(" /samples/checkers/$name " )
18
- val file = loadEtsFileAutoConvert(
19
- path,
20
- useArkAnalyzerTypeInference = 1
21
- )
22
- EtsScene (listOf (file))
23
- }
14
+ // val scene = run {
15
+ // val name = "UnreachableCode.ts"
16
+ // val path = getResourcePath("/samples/checkers/$name")
17
+ // val file = loadEtsFileAutoConvert(
18
+ // path,
19
+ // useArkAnalyzerTypeInference = 1
20
+ // )
21
+ // EtsScene(listOf(file))
22
+ // }
23
+
24
+ val path = getResourcePath(" /projects/Demo_Calc/etsir" )
25
+ val scene = loadEtsProjectFromIR(path, null )
24
26
25
27
val options = UMachineOptions ()
26
28
val tsOptions = TsOptions (interproceduralAnalysis = false )
27
29
val observer = UnreachableCodeDetector ()
28
30
val machine = TsMachine (scene, options, tsOptions, observer, observer)
29
- val methods = scene.projectClasses.flatMap { it.methods }.filter { it.name == " simpleUnreachableBranch" }
31
+ val methods = scene.projectClasses
32
+ .flatMap { it.methods }
33
+ .filterNot { it.cfg.stmts.isEmpty() }
34
+ // .filter { it.name == "simpleUnreachableBranch" }
30
35
val results = machine.analyze(methods)
31
36
32
37
check(results.isNotEmpty())
0 commit comments