Skip to content

Commit 1ea7caf

Browse files
committed
Fix join ordering in inline-expectations test
1 parent 17dd1f6 commit 1ea7caf

File tree

8 files changed

+112
-16
lines changed

8 files changed

+112
-16
lines changed

cpp/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

csharp/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

go/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

java/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

python/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

ql/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

ruby/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

swift/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ abstract private class Expectation extends FailureLocatable {
330330
override Location getLocation() { result = comment.getLocation() }
331331
}
332332

333+
private predicate onSameLine(ValidExpectation a, ActualResult b) {
334+
exists(File f, int line, Location la, Location lb |
335+
// Join order intent:
336+
// Take the locations of ActualResults,
337+
// join with locations in the same file / on the same line,
338+
// then match those against ValidExpectations.
339+
la = a.getLocation() and
340+
pragma[only_bind_into](lb) = b.getLocation() and
341+
locations_default(pragma[only_bind_into](la), f, line, _, _, _) and
342+
locations_default(lb, f, line, _, _, _)
343+
)
344+
}
345+
333346
private class ValidExpectation extends Expectation, TValidExpectation {
334347
string tag;
335348
string value;
@@ -344,8 +357,7 @@ private class ValidExpectation extends Expectation, TValidExpectation {
344357
string getKnownFailure() { result = knownFailure }
345358

346359
predicate matchesActualResult(ActualResult actualResult) {
347-
getLocation().getStartLine() = actualResult.getLocation().getStartLine() and
348-
getLocation().getFile() = actualResult.getLocation().getFile() and
360+
onSameLine(pragma[only_bind_into](this), actualResult) and
349361
getTag() = actualResult.getTag() and
350362
getValue() = actualResult.getValue()
351363
}

0 commit comments

Comments
 (0)