|
1 | | -import java as J |
2 | | - |
3 | | -private signature module InlineMadTestLangSig { |
4 | | - /** |
5 | | - * A base class of callables for modeling. |
6 | | - */ |
7 | | - class Callable; |
8 | | - |
9 | | - /** |
10 | | - * Gets a relevant code comment for `c`, if any. |
11 | | - */ |
12 | | - string getComment(Callable c); |
13 | | -} |
14 | | - |
15 | | -private module InlineMadTestImpl<InlineMadTestLangSig Lang> { |
16 | | - private class Callable = Lang::Callable; |
17 | | - |
18 | | - signature module InlineMadTestConfigSig { |
19 | | - /** |
20 | | - * Gets the kind of a captured model. |
21 | | - */ |
22 | | - string getKind(); |
23 | | - |
24 | | - /** |
25 | | - * Gets a captured model for `c`, if any. |
26 | | - */ |
27 | | - string getCapturedModel(Callable c); |
28 | | - } |
29 | | - |
30 | | - module InlineMadTest<InlineMadTestConfigSig Input> { |
31 | | - private string expects(Callable c) { |
32 | | - Lang::getComment(c).regexpCapture(" *(SPURIOUS-)?" + Input::getKind() + "=(.*)", 2) = result |
33 | | - } |
34 | | - |
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 | | - } |
50 | | - } |
51 | | -} |
| 1 | +private import java as J |
| 2 | +private import codeql.mad.test.InlineMadTest |
52 | 3 |
|
53 | 4 | private module InlineMadTestLang implements InlineMadTestLangSig { |
54 | 5 | class Callable = J::Callable; |
|
0 commit comments