|
1 | 1 | import java |
2 | 2 | import utils.modelgenerator.internal.CaptureTypeBasedSummaryModels |
3 | 3 |
|
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(); |
8 | 14 | } |
9 | 15 |
|
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 | + } |
11 | 28 |
|
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 | + } |
18 | 36 | } |
19 | 37 |
|
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(_) } |
26 | 42 | } |
| 43 | + |
| 44 | +import InlineMadTest<InlineMadTestConfig> |
0 commit comments