Skip to content

Commit b8a91d4

Browse files
committed
Python tests: Add a few tests to check parsing and location of comparisons.
1 parent b4e8808 commit b8a91d4

File tree

10 files changed

+38
-0
lines changed

10 files changed

+38
-0
lines changed

python/ql/test/library-tests/exprs/AstParent.expected renamed to python/ql/test/library-tests/exprs/ast/AstParent.expected

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

python/ql/test/library-tests/exprs/IsConstant.expected renamed to python/ql/test/library-tests/exprs/ast/IsConstant.expected

File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
| compare.py:2:1 | Compare | a | Lt | b |
2+
| compare.py:2:1 | Compare | b | Lt | c |
3+
| compare.py:4:1 | Compare | x | In | y |
4+
| compare.py:5:1 | Compare | x | NotIn | y |
5+
| compare.py:6:1 | Compare | x | Is | y |
6+
| compare.py:7:1 | Compare | x | IsNot | y |
7+
| compare.py:8:1 | Compare | x | Lt | y |
8+
| compare.py:9:1 | Compare | x | Gt | y |
9+
| compare.py:10:1 | Compare | x | GtE | y |
10+
| compare.py:11:1 | Compare | x | LtE | y |
11+
| compare.py:12:1 | Compare | x | Eq | y |
12+
| compare.py:13:1 | Compare | x | NotEq | y |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import python
3+
4+
string loc(AstNode f) {
5+
exists(Location l |
6+
l = f.getLocation() |
7+
result = l.getFile().getBaseName() + ":" + l.getStartLine() + ":" + l.getStartColumn()
8+
)
9+
}
10+
11+
from Compare comp, Expr left, Expr right, Cmpop op
12+
where comp.compares(left, op, right)
13+
select loc(comp), comp.toString(), left.toString(), op.toString(), right.toString()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
a < b < c
3+
4+
x in y
5+
x not in y
6+
x is y
7+
x is not y
8+
x < y
9+
x > y
10+
x >= y
11+
x <= y
12+
x == y
13+
x != y

0 commit comments

Comments
 (0)