@@ -3,6 +3,7 @@ package org.utbot.examples.lambda
3
3
import org.junit.jupiter.api.Test
4
4
import org.utbot.framework.plugin.api.CodegenLanguage
5
5
import org.utbot.testcheckers.eq
6
+ import org.utbot.testcheckers.withConcrete
6
7
import org.utbot.tests.infrastructure.CodeGeneration
7
8
import org.utbot.tests.infrastructure.DoNotCalculate
8
9
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
@@ -57,25 +58,40 @@ class CustomPredicateExampleTest : UtValueTestCaseChecker(
57
58
58
59
@Test
59
60
fun testCapturedStaticFieldPredicateCheck () {
60
- checkWithException (
61
+ checkStatics (
61
62
CustomPredicateExample ::capturedStaticFieldPredicateCheck,
62
63
eq(3 ),
63
- { predicate, x, r -> ! predicate.test(x) && r.getOrNull() == false },
64
- { predicate, x, r -> predicate.test(x) && r.getOrNull() == true },
65
- { predicate, _, r -> predicate == null && r.isException<NullPointerException >() },
64
+ { predicate, x, statics, r ->
65
+ val staticField = statics.values.singleOrNull()?.value as Int
66
+ CustomPredicateExample .someStaticField = staticField
67
+
68
+ ! predicate.test(x) && r == false
69
+ },
70
+ { predicate, x, statics, r ->
71
+ val staticField = statics.values.singleOrNull()?.value as Int
72
+ CustomPredicateExample .someStaticField = staticField
73
+
74
+ predicate.test(x) && r == true
75
+ },
76
+ { predicate, _, _, _ ->
77
+ predicate == null
78
+ },
66
79
coverage = DoNotCalculate
67
80
)
68
81
}
69
82
70
83
@Test
71
84
fun testCapturedNonStaticFieldPredicateCheck () {
72
- checkWithException(
73
- CustomPredicateExample ::capturedNonStaticFieldPredicateCheck,
74
- eq(3 ),
75
- { predicate, x, r -> ! predicate.test(x) && r.getOrNull() == false },
76
- { predicate, x, r -> predicate.test(x) && r.getOrNull() == true },
77
- { predicate, _, r -> predicate == null && r.isException<NullPointerException >() },
78
- coverage = DoNotCalculate
79
- )
85
+ // TODO fails without concrete https://github.com/UnitTestBot/UTBotJava/issues/1247
86
+ withConcrete(useConcreteExecution = true ) {
87
+ checkWithException(
88
+ CustomPredicateExample ::capturedNonStaticFieldPredicateCheck,
89
+ eq(3 ),
90
+ { predicate, x, r -> ! predicate.test(x) && r.getOrNull() == false },
91
+ { predicate, x, r -> predicate.test(x) && r.getOrNull() == true },
92
+ { predicate, _, r -> predicate == null && r.isException<NullPointerException >() },
93
+ coverage = DoNotCalculate
94
+ )
95
+ }
80
96
}
81
97
}
0 commit comments