Files
codeql/csharp/ql/test/library-tests/folding/Folding1.ql
2018-12-20 10:19:59 +01:00

34 lines
713 B
Plaintext

/**
* @name Test that the results of constant folding are recorded, but that the
* original AST is populated.
*/
import csharp
string lost(LocalVariable v) {
v.fromSource() and
v.getInitializer() instanceof Literal and
result = "Folded literal populated - original lost"
}
string noValue(LocalVariable v) {
v.fromSource() and
v.getInitializer() instanceof Literal and
result = "No constant value recorded"
}
string correct(LocalVariable v) {
v.fromSource() and
exists(v.getInitializer()) and
not exists(lost(v)) and
not exists(noValue(v)) and
result = "Correct"
}
from LocalVariable v, string msg
where
msg = lost(v) or
msg = noValue(v) or
msg = correct(v)
select v, msg