Files
codeql/rust/ql/test/library-tests/static_access/static_access.ql
2026-06-02 14:41:27 +02:00

32 lines
935 B
Plaintext

import rust
import utils.test.InlineExpectationsTest
import TestUtils
query predicate staticAccess(StaticAccess sa, Static s) { toBeTested(sa) and s = sa.getStatic() }
module StaticAccessTest implements TestSig {
private predicate staticAt(Static s, string filepath, int line) {
s.getLocation().hasLocationInfo(filepath, _, _, line, _)
}
string getARelevantTag() { result = "static_access" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(StaticAccess sa, Static s, string filepath, int line |
toBeTested(sa) and
location = sa.getLocation() and
element = sa.toString() and
tag = "static_access" and
s = sa.getStatic() and
staticAt(s, filepath, line)
|
commentAt(value, filepath, line)
or
not commentAt(_, filepath, line) and
value = s.getName().getText()
)
}
}
import MakeTest<StaticAccessTest>