Python tests: Add a few tests to check parsing and location of comparisons.

This commit is contained in:
Mark Shannon
2019-01-16 11:27:57 +00:00
parent b4e8808582
commit b8a91d4b1e
10 changed files with 38 additions and 0 deletions

View 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 |

View 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()

View 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