Skip to content

Commit e77dcf0

Browse files
Fix exceptional graph building #656 (#1165)
1 parent 9453e11 commit e77dcf0

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ junit4PlatformVersion=1.9.0
1818
mockitoVersion=3.5.13
1919
z3Version=4.8.9.1
2020
z3JavaApiVersion=4.8.9
21-
sootCommitHash=3adf23c3
21+
sootCommitHash=ed85c59
2222
kotlinVersion=1.7.20
2323
log4j2Version=2.13.3
2424
coroutinesVersion=1.6.3

utbot-framework-test/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.utbot.tests.infrastructure.isException
77
import org.utbot.framework.plugin.api.CodegenLanguage
88
import org.junit.jupiter.api.Test
99
import org.utbot.testcheckers.eq
10+
import org.utbot.testcheckers.withoutConcrete
1011
import org.utbot.tests.infrastructure.CodeGeneration
1112

1213
internal class ExceptionExamplesTest : UtValueTestCaseChecker(
@@ -106,6 +107,23 @@ internal class ExceptionExamplesTest : UtValueTestCaseChecker(
106107
)
107108
}
108109

110+
/**
111+
* Covers [#656](https://github.com/UnitTestBot/UTBotJava/issues/656).
112+
*/
113+
@Test
114+
fun testCatchExceptionAfterOtherPossibleException() {
115+
withoutConcrete {
116+
checkWithException(
117+
ExceptionExamples::catchExceptionAfterOtherPossibleException,
118+
eq(3),
119+
{ i, r -> i == -1 && r.isException<ArithmeticException>() },
120+
{ i, r -> i == 0 && r.getOrThrow() == 2 },
121+
{ i, r -> r.getOrThrow() == 1 },
122+
coverage = atLeast(100)
123+
)
124+
}
125+
}
126+
109127
/**
110128
* Used for path generation check in [org.utbot.engine.Traverser.fullPath]
111129
*/

utbot-sample/src/main/java/org/utbot/examples/exceptions/ExceptionExamples.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ public int catchDeepNestedThrow(int i) {
8686
}
8787
}
8888

89+
public int catchExceptionAfterOtherPossibleException(int i) {
90+
int x = 15;
91+
x /= i + 1;
92+
93+
try {
94+
x /= i;
95+
} catch (RuntimeException e) {
96+
return 2;
97+
}
98+
return 1;
99+
}
100+
89101
public IllegalArgumentException createException() {
90102
return new IllegalArgumentException("Here we are: " + Math.sqrt(10));
91103
}

0 commit comments

Comments
 (0)