Java: Move param module into TestUtilities.

This commit is contained in:
Michael Nebel
2024-05-06 10:19:39 +02:00
parent 105984f7de
commit 6815bcaa80
2 changed files with 34 additions and 34 deletions

View File

@@ -0,0 +1,33 @@
signature module InlineMadTestConfigSig {
/**
* Gets a relevant code comment, if any.
*/
string getComment();
/**
* Gets an identified summary, if any.
*/
string getCapturedSummary();
}
module InlineMadTest<InlineMadTestConfigSig Input> {
private string expects() {
Input::getComment().regexpCapture(" *(SPURIOUS-)?MaD=(.*)", 2) = result
}
query predicate unexpectedSummary(string msg) {
exists(string flow |
flow = Input::getCapturedSummary() and
not flow = expects() and
msg = "Unexpected summary found: " + flow
)
}
query predicate expectedSummary(string msg) {
exists(string e |
e = expects() and
not e = Input::getCapturedSummary() and
msg = "Expected summary missing: " + e
)
}
}

View File

@@ -1,40 +1,7 @@
import java
import TestUtilities.InlineMadTest
import utils.modelgenerator.internal.CaptureTypeBasedSummaryModels
signature module InlineMadTestConfigSig {
/**
* Gets a relevant code comment, if any.
*/
string getComment();
/**
* Gets an identified summary, if any.
*/
string getCapturedSummary();
}
module InlineMadTest<InlineMadTestConfigSig Input> {
private string expects() {
Input::getComment().regexpCapture(" *(SPURIOUS-)?MaD=(.*)", 2) = result
}
query predicate unexpectedSummary(string msg) {
exists(string flow |
flow = Input::getCapturedSummary() and
not flow = expects() and
msg = "Unexpected summary found: " + flow
)
}
query predicate expectedSummary(string msg) {
exists(string e |
e = expects() and
not e = Input::getCapturedSummary() and
msg = "Expected summary missing: " + e
)
}
}
module InlineMadTestConfig implements InlineMadTestConfigSig {
string getComment() { result = any(Javadoc doc).getChild(0).toString() }