|
1 | | -import java |
| 1 | +import java as J |
2 | 2 |
|
3 | 3 | private signature module InlineMadTestLangSig { |
| 4 | + /** |
| 5 | + * A base class of callables for modeling. |
| 6 | + */ |
| 7 | + class Callable; |
| 8 | + |
4 | 9 | /** |
5 | 10 | * Gets a relevant code comment for `c`, if any. |
6 | 11 | */ |
7 | 12 | string getComment(Callable c); |
8 | 13 | } |
9 | 14 |
|
10 | | -signature module InlineMadTestConfigSig { |
11 | | - /** |
12 | | - * Gets the kind of a captured model. |
13 | | - */ |
14 | | - string getKind(); |
| 15 | +private module InlineMadTestImpl<InlineMadTestLangSig Lang> { |
| 16 | + private class Callable = Lang::Callable; |
15 | 17 |
|
16 | | - /** |
17 | | - * Gets a captured model for `c`, if any. |
18 | | - */ |
19 | | - string getCapturedModel(Callable c); |
20 | | -} |
| 18 | + signature module InlineMadTestConfigSig { |
| 19 | + /** |
| 20 | + * Gets the kind of a captured model. |
| 21 | + */ |
| 22 | + string getKind(); |
21 | 23 |
|
22 | | -private module InlineMadTestImpl<InlineMadTestLangSig Lang, InlineMadTestConfigSig Input> { |
23 | | - private string expects(Callable c) { |
24 | | - Lang::getComment(c).regexpCapture(" *(SPURIOUS-)?" + Input::getKind() + "=(.*)", 2) = result |
| 24 | + /** |
| 25 | + * Gets a captured model for `c`, if any. |
| 26 | + */ |
| 27 | + string getCapturedModel(Callable c); |
25 | 28 | } |
26 | 29 |
|
27 | | - query predicate unexpectedModel(string msg) { |
28 | | - exists(Callable c, string flow | |
29 | | - flow = Input::getCapturedModel(c) and |
30 | | - not flow = expects(c) and |
31 | | - msg = "Unexpected " + Input::getKind() + " found: " + flow |
32 | | - ) |
33 | | - } |
| 30 | + module InlineMadTest<InlineMadTestConfigSig Input> { |
| 31 | + private string expects(Callable c) { |
| 32 | + Lang::getComment(c).regexpCapture(" *(SPURIOUS-)?" + Input::getKind() + "=(.*)", 2) = result |
| 33 | + } |
34 | 34 |
|
35 | | - query predicate expectedModel(string msg) { |
36 | | - exists(Callable c, string e | |
37 | | - e = expects(c) and |
38 | | - not e = Input::getCapturedModel(c) and |
39 | | - msg = "Expected " + Input::getKind() + " missing: " + e |
40 | | - ) |
| 35 | + query predicate unexpectedModel(string msg) { |
| 36 | + exists(Callable c, string flow | |
| 37 | + flow = Input::getCapturedModel(c) and |
| 38 | + not flow = expects(c) and |
| 39 | + msg = "Unexpected " + Input::getKind() + " found: " + flow |
| 40 | + ) |
| 41 | + } |
| 42 | + |
| 43 | + query predicate expectedModel(string msg) { |
| 44 | + exists(Callable c, string e | |
| 45 | + e = expects(c) and |
| 46 | + not e = Input::getCapturedModel(c) and |
| 47 | + msg = "Expected " + Input::getKind() + " missing: " + e |
| 48 | + ) |
| 49 | + } |
41 | 50 | } |
42 | 51 | } |
43 | 52 |
|
44 | 53 | private module InlineMadTestLang implements InlineMadTestLangSig { |
| 54 | + class Callable = J::Callable; |
| 55 | + |
45 | 56 | string getComment(Callable c) { |
46 | | - exists(Javadoc doc | |
| 57 | + exists(J::Javadoc doc | |
47 | 58 | hasJavadoc(c, doc) and |
48 | 59 | isNormalComment(doc) and |
49 | 60 | result = doc.getChild(0).toString() |
50 | 61 | ) |
51 | 62 | } |
52 | 63 | } |
53 | 64 |
|
54 | | -module InlineMadTest<InlineMadTestConfigSig Input> { |
55 | | - import InlineMadTestImpl<InlineMadTestLang, Input> |
56 | | -} |
| 65 | +import InlineMadTestImpl<InlineMadTestLang> |
0 commit comments