Create mocks in output values. **CANNOT BE MERGED INTO MAIN**#127
Merged
EgorkaKulikov merged 5 commits intocompetitions_2024from Nov 28, 2023
Merged
Create mocks in output values. **CANNOT BE MERGED INTO MAIN**#127EgorkaKulikov merged 5 commits intocompetitions_2024from
EgorkaKulikov merged 5 commits intocompetitions_2024from
Conversation
Saloed
approved these changes
Nov 21, 2023
9b1acd9 to
a4b05b7
Compare
25263ed to
7672dab
Compare
Collaborator
|
Running on /**
* @utbot.classUnderTest {@link org.usvm.samples.mock.MockRandomExamples}
* @utbot.methodUnderTest {@link org.usvm.samples.mock.MockRandomExamples#randomAsParameter(java.util.Random,int)}
*/
@Test(expected = NullPointerException.class)
public void testRandomAsParameterThrowsNPEWithCornerCase() throws Exception {
MockRandomExamples mockRandomExamples = ((MockRandomExamples) createInstance("org.usvm.samples.mock.MockRandomExamples"));
mockRandomExamples.randomAsParameter(null, 0);
}
/**
* @utbot.classUnderTest {@link org.usvm.samples.mock.MockRandomExamples}
* @utbot.methodUnderTest {@link org.usvm.samples.mock.MockRandomExamples#randomAsParameter(java.util.Random,int)}
*/
@Test(expected = NullPointerException.class)
public void testRandomAsParameterThrowsNPEWithCornerCase1() throws Exception {
MockRandomExamples mockRandomExamples = ((MockRandomExamples) createInstance("org.usvm.samples.mock.MockRandomExamples"));
Random randomMock = mock(Random.class);
setField(randomMock, "java.util.Random", "nextNextGaussian", 0.0);
mockRandomExamples.randomAsParameter(randomMock, 0);
} |
Collaborator
|
@IlyaMuravjov should be fixed now |
DaniilStepanov
approved these changes
Nov 27, 2023
Collaborator
|
@Saloed I am still getting same results on ilya_m/contest/mocks branch (update |
Collaborator
|
Fixed |
a191067 to
cd54352
Compare
IlyaMuravjov
approved these changes
Nov 28, 2023
Collaborator
IlyaMuravjov
left a comment
There was a problem hiding this comment.
Now, two correct tests are generated for org.usvm.samples.mock.MockRandomExamples.randomAsParameter, although there's still unnecessary set field for nextNextGaussian.
/**
* @utbot.classUnderTest {@link org.usvm.samples.mock.MockRandomExamples}
* @utbot.methodUnderTest {@link org.usvm.samples.mock.MockRandomExamples#randomAsParameter(java.util.Random,int)}
*/
@Test
public void testRandomAsParameterReturnsZeroWithCornerCase() throws Exception {
MockRandomExamples mockRandomExamples = ((MockRandomExamples) createInstance("org.usvm.samples.mock.MockRandomExamples"));
Random randomMock = mock(Random.class);
(when(randomMock.nextInt())).thenReturn(0);
setField(randomMock, "java.util.Random", "nextNextGaussian", 0.0);
int actual = mockRandomExamples.randomAsParameter(randomMock, 0);
assertEquals(0, actual);
}
/**
* @utbot.classUnderTest {@link org.usvm.samples.mock.MockRandomExamples}
* @utbot.methodUnderTest {@link org.usvm.samples.mock.MockRandomExamples#randomAsParameter(java.util.Random,int)}
*/
@Test
public void testRandomAsParameterReturnsOneWithCornerCase() throws Exception {
MockRandomExamples mockRandomExamples = ((MockRandomExamples) createInstance("org.usvm.samples.mock.MockRandomExamples"));
Random randomMock = mock(Random.class);
(when(randomMock.nextInt())).thenReturn(1);
setField(randomMock, "java.util.Random", "nextNextGaussian", 0.0);
int actual = mockRandomExamples.randomAsParameter(randomMock, 0);
assertEquals(1, actual);
}2b32268 to
f543adb
Compare
8dbf9ad to
60a961a
Compare
Saloed
added a commit
that referenced
this pull request
Nov 29, 2023
* Create mocks in output values * Rebase * Fix tests * Fix mocks for approximated methods * Remove approximations specific methods filter --------- Co-authored-by: Valentyn Sobol <napster_1997@mail.ru>
Saloed
added a commit
that referenced
this pull request
Feb 14, 2024
* Create mocks in output values * Rebase * Fix tests * Fix mocks for approximated methods * Remove approximations specific methods filter --------- Co-authored-by: Valentyn Sobol <napster_1997@mail.ru>
Saloed
pushed a commit
that referenced
this pull request
Apr 4, 2024
Allow configuring paths to instrumentation jars, approximation jars and java home (#166) Revert "Removed copying <clinit> for interfaces in instrumentation" Fixed Trace Collector Removed copying <clinit> for interfaces in instrumentation Added caching of trace methods Fixed mocking methods of unknown classes Hacked max array size for concrete size Fixed classloader for logger Treat runner timeout as failure Fix jdk internal types Added hack for non-null `value` field in strings (#165) Fix bug with tracing of approximated methods concrete-executor: java home option Types draft concrete-executor: add persistence option Fixed resolving enum values without any constraints approximations: fix map anyKey guarantees jc-test-resolver: class constants core: more safe machine step core: more safe machine step jc-test-resolver: better handling of strings and classes core: better soft constraints jc-interpreter: better exception types jc-interpreter: get rid of unknown classes when possible jc-interpreter: fix getTyped for method jvm-concrete-executor: Don't ignore exceptions in instance allocation Create mocks in output values. **CANNOT BE MERGED INTO MAIN** (#127) * Create mocks in output values * Rebase * Fix tests * Fix mocks for approximated methods * Remove approximations specific methods filter --------- Co-authored-by: Valentyn Sobol <napster_1997@mail.ru> More informative error message Fix compilation after rebase more safe uTestInst execution minor Fix of bug with classloader Flow state collectors (#125) * Avoid `jdk.internal` in `org.usvm.instrumentation.util.URLClassPathLoader` (#94) * Flow collectors --------- Co-authored-by: IlyaMuravjov <71839386+IlyaMuravjov@users.noreply.github.com> Avoid `jdk.internal` in `org.usvm.instrumentation.util.URLClassPathLoader` (#94)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


No description provided.