Skip to content

Commit adbf66a

Browse files
committed
C++: Rewrite inline expectation test to demonstrate MergeTests
1 parent 04beeef commit adbf66a

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
failures
2+
testFailures

cpp/ql/test/library-tests/dataflow/dataflow-tests/has-parameter-flow-out.ql

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ module AstTest {
55
private import semmle.code.cpp.dataflow.DataFlow::DataFlow
66
private import semmle.code.cpp.dataflow.internal.DataFlowPrivate
77

8-
class AstParameterDefTest extends InlineExpectationsTest {
9-
AstParameterDefTest() { this = "AstParameterDefTest" }
8+
module AstParameterDefTest implements TestSig {
9+
string getARelevantTag() { result = "ast-def" }
1010

11-
override string getARelevantTag() { result = "ast-def" }
12-
13-
override predicate hasActualResult(Location location, string element, string tag, string value) {
11+
predicate hasActualResult(Location location, string element, string tag, string value) {
1412
exists(Function f, Parameter p, RefParameterFinalValueNode n |
1513
p.isNamed() and
1614
n.getParameter() = p and
@@ -21,6 +19,10 @@ module AstTest {
2119
value = p.getName()
2220
)
2321
}
22+
23+
predicate hasOptionalResult(Location location, string element, string tag, string value) {
24+
none()
25+
}
2426
}
2527
}
2628

@@ -33,12 +35,10 @@ module IRTest {
3335
(if k = 0 then result = "" else result = "*" + stars(k - 1))
3436
}
3537

36-
class IRParameterDefTest extends InlineExpectationsTest {
37-
IRParameterDefTest() { this = "IRParameterDefTest" }
38-
39-
override string getARelevantTag() { result = "ir-def" }
38+
module IRParameterDefTest implements TestSig {
39+
string getARelevantTag() { result = "ir-def" }
4040

41-
override predicate hasActualResult(Location location, string element, string tag, string value) {
41+
predicate hasActualResult(Location location, string element, string tag, string value) {
4242
exists(Function f, Parameter p, FinalParameterNode n |
4343
p.isNamed() and
4444
n.getParameter() = p and
@@ -49,5 +49,11 @@ module IRTest {
4949
value = stars(n.getIndirectionIndex()) + p.getName()
5050
)
5151
}
52+
53+
predicate hasOptionalResult(Location location, string element, string tag, string value) {
54+
none()
55+
}
5256
}
5357
}
58+
59+
import MakeTest<MergeTests<AstTest::AstParameterDefTest, IRTest::IRParameterDefTest>>

0 commit comments

Comments
 (0)