Skip to content

Commit 8a8a7ea

Browse files
committed
Swift: Add tests for ArithmeticOperation.qll.
1 parent a5fff9a commit 8a8a7ea

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| arithmeticoperation.swift:6:6:6:10 | ... call to +(_:_:) ... | AddExpr, BinaryArithmeticOperation |
2+
| arithmeticoperation.swift:7:6:7:10 | ... call to -(_:_:) ... | BinaryArithmeticOperation, SubExpr |
3+
| arithmeticoperation.swift:8:6:8:10 | ... call to *(_:_:) ... | BinaryArithmeticOperation, MulExpr |
4+
| arithmeticoperation.swift:9:6:9:10 | ... call to /(_:_:) ... | BinaryArithmeticOperation, DivExpr |
5+
| arithmeticoperation.swift:10:6:10:10 | ... call to %(_:_:) ... | BinaryArithmeticOperation, RemExpr |
6+
| arithmeticoperation.swift:11:6:11:7 | call to ... | UnaryArithmeticOperation, UnaryMinusExpr |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import swift
2+
3+
string describe(ArithmeticOperation e) {
4+
(e instanceof BinaryArithmeticOperation and result = "BinaryArithmeticOperation") or
5+
(e instanceof AddExpr and result = "AddExpr") or
6+
(e instanceof SubExpr and result = "SubExpr") or
7+
(e instanceof MulExpr and result = "MulExpr") or
8+
(e instanceof DivExpr and result = "DivExpr") or
9+
(e instanceof RemExpr and result = "RemExpr") or
10+
(e instanceof UnaryArithmeticOperation and result = "UnaryArithmeticOperation") or
11+
(e instanceof UnaryMinusExpr and result = "UnaryMinusExpr")
12+
}
13+
14+
from ArithmeticOperation e
15+
select e, concat(describe(e), ", ")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
func test(c: Bool, x: Int, y: Int, z: Int) {
3+
var v = 0
4+
5+
// arithmetic operations
6+
v = x + y;
7+
v = x - 1;
8+
v = 2 * y;
9+
v = 3 / 4;
10+
v = x % y;
11+
v = -x;
12+
}

0 commit comments

Comments
 (0)