Skip to content

Commit 56dbfd0

Browse files
committed
Fixed matchers for lambda test
1 parent a8d1f92 commit 56dbfd0

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/examples/lambda/CustomPredicateExampleTest.kt

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.utbot.examples.lambda
33
import org.junit.jupiter.api.Test
44
import org.utbot.framework.plugin.api.CodegenLanguage
55
import org.utbot.testcheckers.eq
6+
import org.utbot.testcheckers.withConcrete
67
import org.utbot.tests.infrastructure.CodeGeneration
78
import org.utbot.tests.infrastructure.DoNotCalculate
89
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
@@ -57,25 +58,40 @@ class CustomPredicateExampleTest : UtValueTestCaseChecker(
5758

5859
@Test
5960
fun testCapturedStaticFieldPredicateCheck() {
60-
checkWithException(
61+
checkStatics(
6162
CustomPredicateExample::capturedStaticFieldPredicateCheck,
6263
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+
},
6679
coverage = DoNotCalculate
6780
)
6881
}
6982

7083
@Test
7184
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+
}
8096
}
8197
}

0 commit comments

Comments
 (0)