GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Primitive Stream wrappers (no laziness and source mutations support) by Damtev · Pull Request #871 · UnitTestBot/UTBotJava

Primitive Stream wrappers (no laziness and source mutations support) #871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Damtev merged 19 commits into main from damtev/primitive_stream_wrappers_arrays
Sep 28, 2022

Uh oh!

There was an error while loading. Please reload this page.

Merged

Primitive Stream wrappers (no laziness and source mutations support) #871

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2b60de7
Fixed repeated `hashCode` calculation for `Edge`
Damtev Jul 12, 2022
b362960
Disabled strange failed naming check
Damtev Jul 22, 2022
adb0cec
Implemented wrappers for primitive streams
Damtev Jul 21, 2022
fc5d7eb
Added tests for primitive streams
Damtev Jul 21, 2022
91c6b74
Added `toArray` without ClassCastException check API
Damtev Jul 21, 2022
9797973
Restricted steps limit for a few tests (HACK)
Damtev Aug 1, 2022
75b2de8
Fixed UNSAT core debug logging
Damtev Sep 7, 2022
9ce941e
Fixed rebase errors
Damtev Sep 7, 2022
4a69e0b
Added wrapped methods for creating streams from primitive arrays
Damtev Sep 7, 2022
01ad8e5
Fixed failed tests
Damtev Sep 7, 2022
47b1b7b
Disabled distinct test
Damtev Sep 14, 2022
58c15a2
Fixed array casts
Damtev Sep 16, 2022
ff79a92
Fixed review issues
Damtev Sep 26, 2022
78c9c4f
More fixes for review issues
Damtev Sep 27, 2022
40ebea6
Fixed type resolving
Damtev Sep 27, 2022
a5d9da8
Fixed wrong resolved values for a primitive stream as a parameter
Damtev Sep 27, 2022
2aeb263
Marked primitive stream tests as slow
Damtev Sep 28, 2022
e3381ef
Fixed last review issues
Damtev Sep 28, 2022
d9e4a42
Marked mapTo* primitive stream tests as slow
Damtev Sep 28, 2022
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

3 changes: 3 additions & 0 deletions 3 utbot-api/src/main/java/org/utbot/api/mock/UtMock.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ public static void assumeOrExecuteConcretely(boolean predicate) {
// In oppose to assume, we don't have predicate check here
// to avoid RuntimeException during concrete execution
}

@SuppressWarnings("unused")
public static void disableClassCastExceptionCheck(Object object) {}
}
10 changes: 10 additions & 0 deletions 10 utbot-framework-api/src/main/kotlin/org/utbot/testcheckers/SettingsModificators.kt
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,13 @@ inline fun <reified T> withoutSandbox(block: () -> T): T {
UtSettings.useSandbox = prev
}
}

inline fun <reified T> withPathSelectorStepsLimit(stepsLimit: Int, block: () -> T): T {
val prev = UtSettings.pathSelectorStepsLimit
UtSettings.pathSelectorStepsLimit = stepsLimit
try {
return block()
} finally {
UtSettings.pathSelectorStepsLimit = prev
}
}
103 changes: 86 additions & 17 deletions 103 utbot-framework-test/src/test/kotlin/org/utbot/examples/stream/BaseStreamExampleTest.kt
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.utbot.tests.infrastructure.isException
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.testcheckers.eq
import org.utbot.testcheckers.withoutConcrete
import org.utbot.tests.infrastructure.AtLeast
import org.utbot.tests.infrastructure.CodeGeneration
import java.util.Optional
import java.util.stream.Stream
Expand Down Expand Up @@ -69,10 +70,46 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
fun testMapExample() {
checkWithException(
BaseStreamExample::mapExample,
eq(2),
ignoreExecutionsNumber,
{ c, r -> null in c && r.isException<NullPointerException>() },
{ c, r -> r.getOrThrow().contentEquals(c.map { it * 2 }.toTypedArray()) },
coverage = DoNotCalculate
coverage = AtLeast(90)
)
}

@Test
@Tag("slow")
fun testMapToIntExample() {
checkWithException(
BaseStreamExample::mapToIntExample,
ignoreExecutionsNumber,
{ c, r -> null in c && r.isException<NullPointerException>() },
{ c, r -> r.getOrThrow().contentEquals(c.map { it.toInt() }.toIntArray()) },
coverage = AtLeast(90)
)
}

@Test
@Tag("slow")
fun testMapToLongExample() {
checkWithException(
BaseStreamExample::mapToLongExample,
ignoreExecutionsNumber,
{ c, r -> null in c && r.isException<NullPointerException>() },
{ c, r -> r.getOrThrow().contentEquals(c.map { it.toLong() }.toLongArray()) },
coverage = AtLeast(90)
)
}

@Test
@Tag("slow")
fun testMapToDoubleExample() {
checkWithException(
BaseStreamExample::mapToDoubleExample,
ignoreExecutionsNumber,
{ c, r -> null in c && r.isException<NullPointerException>() },
{ c, r -> r.getOrThrow().contentEquals(c.map { it.toDouble() }.toDoubleArray()) },
coverage = AtLeast(90)
)
}

Expand All @@ -86,6 +123,37 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
)
}

@Test
@Tag("slow")
fun testFlatMapToIntExample() {
check(
BaseStreamExample::flatMapToIntExample,
ignoreExecutionsNumber,
{ c, r -> r.contentEquals(c.flatMap { listOf(it?.toInt() ?: 0, it?.toInt() ?: 0) }.toIntArray()) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
fun testFlatMapToLongExample() {
check(
BaseStreamExample::flatMapToLongExample,
ignoreExecutionsNumber,
{ c, r -> r.contentEquals(c.flatMap { listOf(it?.toLong() ?: 0L, it?.toLong() ?: 0L) }.toLongArray()) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
fun testFlatMapToDoubleExample() {
check(
BaseStreamExample::flatMapToDoubleExample,
ignoreExecutionsNumber,
{ c, r -> r.contentEquals(c.flatMap { listOf(it?.toDouble() ?: 0.0, it?.toDouble() ?: 0.0) }.toDoubleArray()) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
}

@Test
@Tag("slow")
fun testDistinctExample() {
Expand Down Expand Up @@ -146,17 +214,17 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
fun testForEachExample() {
checkThisAndStaticsAfter(
BaseStreamExample::forEachExample,
eq(2),
ignoreExecutionsNumber,
*streamConsumerStaticsMatchers,
coverage = DoNotCalculate
coverage = AtLeast(92)
)
}

@Test
fun testToArrayExample() {
check(
BaseStreamExample::toArrayExample,
ignoreExecutionsNumber,
eq(2),
{ c, r -> c.toTypedArray().contentEquals(r) },
coverage = FullWithAssumptions(assumeCallsNumber = 1)
)
Expand Down Expand Up @@ -311,10 +379,11 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
fun testIteratorExample() {
checkWithException(
BaseStreamExample::iteratorSumExample,
eq(2),
ignoreExecutionsNumber,
{ c, r -> c.isEmpty() && r.getOrThrow() == 0 },
{ c, r -> null in c && r.isException<NullPointerException>() },
{ c, r -> null !in c && r.getOrThrow() == c.sum() },
coverage = DoNotCalculate
{ c, r -> c.isNotEmpty() && null !in c && r.getOrThrow() == c.sum() },
coverage = AtLeast(75)
)
}

Expand Down Expand Up @@ -393,15 +462,15 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
coverage = Full
)
}
}

private val streamConsumerStaticsMatchers = arrayOf(
{ _: BaseStreamExample, c: List<Int?>, _: StaticsType, _: Int? -> null in c },
{ _: BaseStreamExample, c: List<Int?>, statics: StaticsType, r: Int? ->
val x = statics.values.single().value as Int
internal val streamConsumerStaticsMatchers = arrayOf(
{ _: Any, c: List<Int?>, _: StaticsType, _: Int? -> null in c },
{ _: Any, c: List<Int?>, statics: StaticsType, r: Int? ->
val x = statics.values.single().value as Int

r!! + c.sumOf { it ?: 0 } == x
}
)
}
r!! + c.sumOf { it ?: 0 } == x
}
)

private fun <E : Comparable<E>> Sequence<E>.isSorted(): Boolean = zipWithNext { a, b -> a <= b }.all { it }
internal fun <E : Comparable<E>> Sequence<E>.isSorted(): Boolean = zipWithNext { a, b -> a <= b }.all { it }
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.