File tree Expand file tree Collapse file tree 3 files changed +15
-14
lines changed
utbot-framework-test/src/test/kotlin/org/utbot/examples/stream
utbot-framework/src/main/kotlin/org/utbot/engine
utbot-sample/src/main/java/org/utbot/examples/stream Expand file tree Collapse file tree 3 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -343,14 +343,13 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
343
343
}
344
344
345
345
@Test
346
- @Disabled(" TODO unsat type constraints https://github.com/UnitTestBot/UTBotJava/issues/253" )
347
346
fun testCustomCollectionStreamExample () {
348
347
check(
349
348
BaseStreamExample ::customCollectionStreamExample,
350
349
ignoreExecutionsNumber,
351
350
{ c, r -> c.isEmpty() && r == 0L },
352
351
{ c, r -> c.isNotEmpty() && c.size.toLong() == r },
353
- coverage = DoNotCalculate
352
+ coverage = DoNotCalculate // TODO failed coverage calculation
354
353
)
355
354
}
356
355
Original file line number Diff line number Diff line change @@ -2346,8 +2346,15 @@ class Traverser(
2346
2346
// for objects (especially objects with type equals to type parameter of generic)
2347
2347
// better than engine.
2348
2348
val types = instanceOfConstraint?.typeStorage?.possibleConcreteTypes ? : instance.possibleConcreteTypes
2349
- val methodInvocationTargets = findLibraryTargets(instance.type, methodSubSignature)
2350
- ? : findMethodInvocationTargets(types, methodSubSignature)
2349
+
2350
+ val allPossibleConcreteTypes = typeResolver
2351
+ .constructTypeStorage(instance.type, useConcreteType = false )
2352
+ .possibleConcreteTypes
2353
+
2354
+ val methodInvocationTargets = findLibraryTargets(instance.type, methodSubSignature)?.takeIf {
2355
+ // we have no specified types, so we can take only library targets (if present) for optimization purposes
2356
+ types.size == allPossibleConcreteTypes.size
2357
+ } ? : findMethodInvocationTargets(types, methodSubSignature)
2351
2358
2352
2359
return methodInvocationTargets
2353
2360
.map { (method, implementationClass, possibleTypes) ->
Original file line number Diff line number Diff line change @@ -410,21 +410,16 @@ long closedStreamExample(List<Integer> values) {
410
410
}
411
411
412
412
@ SuppressWarnings ({"ReplaceInefficientStreamCount" , "ConstantConditions" })
413
+ // TODO wrong generic type for data field https://github.com/UnitTestBot/UTBotJava/issues/730
413
414
long customCollectionStreamExample (CustomCollection <Integer > customCollection ) {
414
415
UtMock .assume (customCollection != null && customCollection .data != null );
415
416
416
- if (customCollection .isEmpty ()) {
417
- return customCollection .stream ().count ();
417
+ final Stream <Integer > stream = customCollection .stream ();
418
418
419
- // simplified example, does not generate branch too
420
- /*customCollection.removeIf(Objects::isNull);
421
- return customCollection.toArray().length;*/
419
+ if (customCollection .isEmpty ()) {
420
+ return stream .count ();
422
421
} else {
423
- return customCollection .stream ().count ();
424
-
425
- // simplified example, does not generate branch too
426
- /*customCollection.removeIf(Objects::isNull);
427
- return customCollection.toArray().length;*/
422
+ return stream .count ();
428
423
}
429
424
}
430
425
You can’t perform that action at this time.
0 commit comments