- Notifications
You must be signed in to change notification settings - Fork45
Fuzzer should change objects with its public setters#439
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.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| fieldValues.asSequence().mapIndexedNotNull { index, value-> | ||
| val field= fields[index] | ||
| when { | ||
| field.setter!=null->UtExecutableCallModel( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We prefer direct accessors inAssembleModelGenerator.chooseModificator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
At the moment fuzzing depends on only framework-api module. Therefore,AssembleModelGenerator.chooseModificator can be accessed from fuzzing module.
| FieldDescription( | ||
| field.name, | ||
| field.type.id, | ||
| field.isPublic&&!field.isFinal&&!field.isStatic, |
EgorkaKulikovJul 11, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why only public, not package private, it sometimes also can be set directly
| null | ||
| } | ||
| } | ||
| privatevalField.isPublic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why do you prefer to do all this logic on aField, not on aFieldId? Related to top level methods too.
| it hasModifier.PUBLIC&& | ||
| it.name== setterName&& | ||
| it.parameterCount==1&& | ||
| it.parameterTypes[0]== field.type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Possibly we should enlargeStatementsStorage.isSetterOrDirectAccessor method with this type check.
| privatevalField.isStatic | ||
| get()= has(Modifier.STATIC) | ||
| privateinfixfun Field.has(modifier:Int)= (modifiersand modifier)!=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I do not understand what happens in this line and in the next one...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The functionhas takesfield.modifiers as integer with bitmask for a concreate modifier flag (STATIC in this sample) and then compares it with 0. If it is 0 then the flag wasn't set in field.modifiers. In Java it looks like:
field.getModifiers() &Modifier.STATIC !=0
That checks that this field is static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I replaced it with methodisAccessible(modifiers: Int, packageName: String?)
EgorkaKulikov left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Left several comments, important moment are that direct accessor is now considered more important than setter and missed package-private fields in the lists of candidates for direct accessing.
… by its public setters#289
Description
Fuzzing now can create object with empty constructor and change that object with public field or field setter if exists.
Setter can have any return type but must have corresponding getter.
Fixes#289
Type of Change
How Has This Been Tested?
Automated Testing
org.utbot.framework.plugin.api.ModelProviderTest#test complex object is created with settersManual Scenario
Try to generate test for method
equalsTofrom this class:Example of result test:
Checklist (remove irrelevant options):