@@ -27,8 +27,8 @@ class CustomJavaDocCommentBuilder(
27
27
docStatementList + = DocRegularStmt (" @utbot.expectedResult ${comment.expectedResult} \n " )
28
28
if (comment.actualResult != null )
29
29
docStatementList + = DocRegularStmt (" @utbot.actualResult ${comment.actualResult} \n " )
30
- if (comment.executes != null )
31
- docStatementList + = DocRegularStmt (" @utbot.executes ${comment.executes } \n " )
30
+ if (comment.executesCondition != null )
31
+ docStatementList + = DocRegularStmt (" @utbot.executesCondition ${comment.executesCondition } \n " )
32
32
if (comment.invokes != null )
33
33
docStatementList + = DocRegularStmt (" @utbot.invokes ${comment.invokes} \n " )
34
34
if (comment.iterates != null )
@@ -46,33 +46,47 @@ class CustomJavaDocCommentBuilder(
46
46
getMethodReference(currentMethod.declaringClass.name, currentMethod.name, currentMethod.parameterTypes)
47
47
val classReference = getClassReference(currentMethod.declaringClass.javaStyleName)
48
48
49
- val thrownException = traceTag.result.exceptionOrNull()
50
- val exceptionThrow: String? = if (thrownException == null ) {
51
- traceTag.result.exceptionOrNull()?.let { it::class .qualifiedName }
52
- } else {
53
- val exceptionName = thrownException.javaClass.simpleName
54
- val reason = findExceptionReason(currentMethod, thrownException)
55
- " {@link $exceptionName } $reason "
56
- }
57
-
58
49
val customJavaDocComment = CustomJavaDocComment (
59
50
classUnderTest = classReference,
60
51
methodUnderTest = methodReference,
61
52
expectedResult = null ,
62
53
actualResult = null ,
63
- executes = null ,
54
+ executesCondition = null ,
64
55
invokes = null ,
65
56
iterates = null ,
66
57
returnsFrom = null ,
67
- throwsException = exceptionThrow
58
+ throwsException = null
68
59
)
69
60
70
- val rootSentenceBlock = SimpleSentenceBlock (stringTemplates = stringTemplates)
61
+ // build throws exception section
62
+ val thrownException = traceTag.result.exceptionOrNull()
63
+ val exceptionThrow: String? = if (thrownException == null ) {
64
+ traceTag.result.exceptionOrNull()?.let { it::class .qualifiedName }
65
+ } else {
66
+ val exceptionName = thrownException.javaClass.simpleName
67
+ val reason = findExceptionReason(currentMethod, thrownException)
68
+ " {@link $exceptionName } $reason "
69
+ }
70
+ customJavaDocComment.throwsException = exceptionThrow
71
71
72
+ val rootSentenceBlock = SimpleSentenceBlock (stringTemplates = stringTemplates)
73
+ skippedIterations()
72
74
buildSentenceBlock(traceTag.rootStatementTag, rootSentenceBlock, currentMethod)
73
75
76
+ // builds iterates section
77
+ rootSentenceBlock.iterationSentenceBlocks.forEach { (loopDesc, sentenceBlocks) ->
78
+ customJavaDocComment.iterates = stringTemplates.iterationSentence.format(
79
+ stringTemplates.codeSentence.format(loopDesc),
80
+ numberOccurrencesToText(
81
+ sentenceBlocks.size
82
+ )
83
+ )
84
+ }
85
+
86
+ // build invokes, executes, and returns from sections
74
87
for (stmtDescription: StmtDescription in rootSentenceBlock.stmtTexts) {
75
88
when (stmtDescription.stmtType.name) {
89
+ // TODO: support multiple invokes (calls)
76
90
" Invoke" -> {
77
91
val info = stmtDescription.description
78
92
customJavaDocComment.invokes = " {@code $info }"
@@ -81,9 +95,10 @@ class CustomJavaDocCommentBuilder(
81
95
val info = stmtDescription.description
82
96
customJavaDocComment.returnsFrom = " {@code $info }"
83
97
}
98
+ // TODO: support multiple conditions
84
99
" Condition" -> {
85
100
val info = stmtDescription.description
86
- customJavaDocComment.executes = " {@code $info }"
101
+ customJavaDocComment.executesCondition = " {@code $info }"
87
102
}
88
103
}
89
104
}
0 commit comments