InlineExpectationsTest: Add test showing what happens if you leave out getARelevantTag

This commit is contained in:
Rasmus Wriedt Larsen
2022-10-26 18:00:03 +02:00
parent 3d025ea77e
commit bfe9aa1225
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1 @@
| test.py:4:1:4:3 | foo | Unexpected result: foo=val |

View File

@@ -0,0 +1,20 @@
// test to illustrate what happens if you forget to put in the
// right values for `getARelevantTag`. We want to alert on this,
// so it gets fixed!
import python
import TestUtilities.InlineExpectationsTest
class MissingRelevantTag extends InlineExpectationsTest {
MissingRelevantTag() { this = "MissingRelevantTag" }
override string getARelevantTag() { none() }
override predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Name name | name.getId() = "foo" |
location = name.getLocation() and
element = name.toString() and
value = "val" and
tag = "foo"
)
}
}

View File

@@ -0,0 +1,7 @@
foo # $ foo=val
# with wrong value
foo # $ foo=bad-value
# there is a typo here, so this result is actually missing!
fooo # $ foo=val