mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python tests: Add a few tests to check parsing and location of comparisons.
This commit is contained in:
12
python/ql/test/library-tests/exprs/compare/Test.expected
Normal file
12
python/ql/test/library-tests/exprs/compare/Test.expected
Normal file
@@ -0,0 +1,12 @@
|
||||
| compare.py:2:1 | Compare | a | Lt | b |
|
||||
| compare.py:2:1 | Compare | b | Lt | c |
|
||||
| compare.py:4:1 | Compare | x | In | y |
|
||||
| compare.py:5:1 | Compare | x | NotIn | y |
|
||||
| compare.py:6:1 | Compare | x | Is | y |
|
||||
| compare.py:7:1 | Compare | x | IsNot | y |
|
||||
| compare.py:8:1 | Compare | x | Lt | y |
|
||||
| compare.py:9:1 | Compare | x | Gt | y |
|
||||
| compare.py:10:1 | Compare | x | GtE | y |
|
||||
| compare.py:11:1 | Compare | x | LtE | y |
|
||||
| compare.py:12:1 | Compare | x | Eq | y |
|
||||
| compare.py:13:1 | Compare | x | NotEq | y |
|
||||
13
python/ql/test/library-tests/exprs/compare/Test.ql
Normal file
13
python/ql/test/library-tests/exprs/compare/Test.ql
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
import python
|
||||
|
||||
string loc(AstNode f) {
|
||||
exists(Location l |
|
||||
l = f.getLocation() |
|
||||
result = l.getFile().getBaseName() + ":" + l.getStartLine() + ":" + l.getStartColumn()
|
||||
)
|
||||
}
|
||||
|
||||
from Compare comp, Expr left, Expr right, Cmpop op
|
||||
where comp.compares(left, op, right)
|
||||
select loc(comp), comp.toString(), left.toString(), op.toString(), right.toString()
|
||||
13
python/ql/test/library-tests/exprs/compare/compare.py
Normal file
13
python/ql/test/library-tests/exprs/compare/compare.py
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
a < b < c
|
||||
|
||||
x in y
|
||||
x not in y
|
||||
x is y
|
||||
x is not y
|
||||
x < y
|
||||
x > y
|
||||
x >= y
|
||||
x <= y
|
||||
x == y
|
||||
x != y
|
||||
Reference in New Issue
Block a user