Skip to content

Commit 105984f

Browse files
committed
Java: Make param module for MaD inline test.
1 parent 6233da3 commit 105984f

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed
Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
import java
22
import utils.modelgenerator.internal.CaptureTypeBasedSummaryModels
33

4-
private string expects() {
5-
exists(Javadoc doc |
6-
doc.getChild(0).toString().regexpCapture(" *(SPURIOUS-)?MaD=(.*)", 2) = result
7-
)
4+
signature module InlineMadTestConfigSig {
5+
/**
6+
* Gets a relevant code comment, if any.
7+
*/
8+
string getComment();
9+
10+
/**
11+
* Gets an identified summary, if any.
12+
*/
13+
string getCapturedSummary();
814
}
915

10-
private string flows() { result = captureFlow(_) }
16+
module InlineMadTest<InlineMadTestConfigSig Input> {
17+
private string expects() {
18+
Input::getComment().regexpCapture(" *(SPURIOUS-)?MaD=(.*)", 2) = result
19+
}
20+
21+
query predicate unexpectedSummary(string msg) {
22+
exists(string flow |
23+
flow = Input::getCapturedSummary() and
24+
not flow = expects() and
25+
msg = "Unexpected summary found: " + flow
26+
)
27+
}
1128

12-
query predicate unexpectedSummary(string msg) {
13-
exists(string flow |
14-
flow = flows() and
15-
not flow = expects() and
16-
msg = "Unexpected summary found: " + flow
17-
)
29+
query predicate expectedSummary(string msg) {
30+
exists(string e |
31+
e = expects() and
32+
not e = Input::getCapturedSummary() and
33+
msg = "Expected summary missing: " + e
34+
)
35+
}
1836
}
1937

20-
query predicate expectedSummary(string msg) {
21-
exists(string e |
22-
e = expects() and
23-
not e = flows() and
24-
msg = "Expected summary missing: " + e
25-
)
38+
module InlineMadTestConfig implements InlineMadTestConfigSig {
39+
string getComment() { result = any(Javadoc doc).getChild(0).toString() }
40+
41+
string getCapturedSummary() { result = captureFlow(_) }
2642
}
43+
44+
import InlineMadTest<InlineMadTestConfig>

0 commit comments

Comments
 (0)