|
1 | | -signature module InlineMadTestConfigSig { |
| 1 | +import java |
| 2 | + |
| 3 | +private signature module InlineMadTestLangSig { |
2 | 4 | /** |
3 | 5 | * Gets a relevant code comment, if any. |
4 | 6 | */ |
5 | 7 | string getComment(); |
| 8 | +} |
| 9 | + |
| 10 | +signature module InlineMadTestConfigSig { |
| 11 | + /** |
| 12 | + * Gets the kind of the captured model. |
| 13 | + */ |
| 14 | + string getKind(); |
6 | 15 |
|
7 | 16 | /** |
8 | | - * Gets an identified summary, if any. |
| 17 | + * Gets a captured model, if any. |
9 | 18 | */ |
10 | | - string getCapturedSummary(); |
| 19 | + string getCapturedModel(); |
11 | 20 | } |
12 | 21 |
|
13 | | -module InlineMadTest<InlineMadTestConfigSig Input> { |
14 | | - bindingset[kind] |
15 | | - private string expects(string kind) { |
16 | | - Input::getComment().regexpCapture(" *(SPURIOUS-)?" + kind + "=(.*)", 2) = result |
| 22 | +private module InlineMadTestImpl<InlineMadTestLangSig Lang, InlineMadTestConfigSig Input> { |
| 23 | + private string expects() { |
| 24 | + Lang::getComment().regexpCapture(" *(SPURIOUS-)?" + Input::getKind() + "=(.*)", 2) = result |
17 | 25 | } |
18 | 26 |
|
19 | | - query predicate unexpectedSummary(string msg) { |
| 27 | + query predicate unexpectedModel(string msg) { |
20 | 28 | exists(string flow | |
21 | | - flow = Input::getCapturedSummary() and |
22 | | - not flow = expects("summary") and |
23 | | - msg = "Unexpected summary found: " + flow |
| 29 | + flow = Input::getCapturedModel() and |
| 30 | + not flow = expects() and |
| 31 | + msg = "Unexpected " + Input::getKind() + " found: " + flow |
24 | 32 | ) |
25 | 33 | } |
26 | 34 |
|
27 | | - query predicate expectedSummary(string msg) { |
| 35 | + query predicate expectedModel(string msg) { |
28 | 36 | exists(string e | |
29 | | - e = expects("summary") and |
30 | | - not e = Input::getCapturedSummary() and |
31 | | - msg = "Expected summary missing: " + e |
| 37 | + e = expects() and |
| 38 | + not e = Input::getCapturedModel() and |
| 39 | + msg = "Expected " + Input::getKind() + " missing: " + e |
32 | 40 | ) |
33 | 41 | } |
34 | 42 | } |
| 43 | + |
| 44 | +private module InlineMadTestLang implements InlineMadTestLangSig { |
| 45 | + string getComment() { result = any(Javadoc doc).getChild(0).toString() } |
| 46 | +} |
| 47 | + |
| 48 | +module InlineMadTest<InlineMadTestConfigSig Input> { |
| 49 | + import InlineMadTestImpl<InlineMadTestLang, Input> |
| 50 | +} |
0 commit comments