Disable test generation for synthetic methods of data classes #1191#1192
Conversation
2f9f48e to
8911095
Compare
| if (method.classId.isEnum) | ||
| method.humanReadableName.substringBefore('(') in KnownSyntheticMethodNames.enumSyntheticMethodNames | ||
| else | ||
| false | ||
| return method.name in KnownSyntheticMethodNames.enumSyntheticMethodNames | ||
|
|
||
| if (method.classId.isData) | ||
| return KnownSyntheticMethodNames.dataClassSyntheticMethodNames.any { it.matches(method.name) } | ||
|
|
||
| return false |
There was a problem hiding this comment.
when may be better here, I suppose
There was a problem hiding this comment.
Is it possible here? isEnum and isData are just properties...
There was a problem hiding this comment.
Just a simple one, like
when {
method.classId.isEnum -> ...
method.classId.isData -> ...
else -> ...
}| "hashCode", | ||
| "toString", | ||
| "copy", | ||
| "copy\\\$default", |
There was a problem hiding this comment.
What is this method? Add some comments about it, please
There was a problem hiding this comment.
It is JVM-synthetic and needed when copy is called with default parameters, after last commit it is not needed here.
| /** List with names of enum methods that are autogenerated */ | ||
| val enumSyntheticMethodNames = listOf("values", "valueOf") | ||
|
|
||
| /** List with names of data classes methods that are autogenerated in Kotlin */ |
There was a problem hiding this comment.
Mention that they are actually regexps, please
There was a problem hiding this comment.
Fixed, also changed the property name for more clarity
Damtev
left a comment
There was a problem hiding this comment.
What about overridden methods in data classes for CLI?
| if (method.classId.isData) | ||
| return KnownSyntheticMethodNames.dataClassSyntheticMethodNames.any { it.matches(method.name) } |
There was a problem hiding this comment.
Am I right that CLI will not generate test methods for overridden "synthetic" methods in data classes (equals, for example)?
There was a problem hiding this comment.
Yes, and it seems difficult (or impossible) to check if the method is not compiler-generated but overridden by user (but if you know the way, I would appreciate hearing it). Added a comment to code about this.
8911095 to
31ada23
Compare
31ada23 to
9b1dc38
Compare
9b1dc38 to
b9ffd0f
Compare
b9ffd0f to
0867c5a
Compare
Description
Added filters so that autogenerated by Kotlin methods of data classes are not tested by plugin/cli/contestEstimator
Fixes #1191
Type of Change
How Has This Been Tested?
Manual Scenario
Tested the behavior in plugin -- autogenerated methods are not added to memberlist (unless they are overridden).
In cli tests for autogenerated methods are also not generated.
Checklist (remove irrelevant options):