Skip to content

Commit 6815bca

Browse files
committed
Java: Move param module into TestUtilities.
1 parent 105984f commit 6815bca

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
signature module InlineMadTestConfigSig {
2+
/**
3+
* Gets a relevant code comment, if any.
4+
*/
5+
string getComment();
6+
7+
/**
8+
* Gets an identified summary, if any.
9+
*/
10+
string getCapturedSummary();
11+
}
12+
13+
module InlineMadTest<InlineMadTestConfigSig Input> {
14+
private string expects() {
15+
Input::getComment().regexpCapture(" *(SPURIOUS-)?MaD=(.*)", 2) = result
16+
}
17+
18+
query predicate unexpectedSummary(string msg) {
19+
exists(string flow |
20+
flow = Input::getCapturedSummary() and
21+
not flow = expects() and
22+
msg = "Unexpected summary found: " + flow
23+
)
24+
}
25+
26+
query predicate expectedSummary(string msg) {
27+
exists(string e |
28+
e = expects() and
29+
not e = Input::getCapturedSummary() and
30+
msg = "Expected summary missing: " + e
31+
)
32+
}
33+
}

java/ql/test/utils/modelgenerator/typebasedflow/CaptureTypeBasedSummaryModels.ql

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,7 @@
11
import java
2+
import TestUtilities.InlineMadTest
23
import utils.modelgenerator.internal.CaptureTypeBasedSummaryModels
34

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();
14-
}
15-
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-
}
28-
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-
}
36-
}
37-
385
module InlineMadTestConfig implements InlineMadTestConfigSig {
396
string getComment() { result = any(Javadoc doc).getChild(0).toString() }
407

0 commit comments

Comments
 (0)