Skip to content

Commit aaa89f7

Browse files
committed
Swift: Add a test for assignment exprs.
1 parent d734982 commit aaa89f7

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| assignment.swift:6:2:6:6 | ... = ... | AssignExpr | x | 1 |
2+
| assignment.swift:33:2:33:6 | ... = ... | AssignExpr | y | z |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import swift
2+
3+
string describe(Expr e) {
4+
e instanceof AssignExpr and result = "AssignExpr"
5+
}
6+
7+
from AssignExpr e
8+
where
9+
e.getLocation().getFile().getBaseName() != ""
10+
select
11+
e,
12+
concat(describe(e), ", "),
13+
concat(e.getDest().toString(), ", "),
14+
concat(e.getSource().toString(), ", ")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
func test() {
3+
var x = 0
4+
5+
// simple assignment
6+
x = 1
7+
8+
// arithmetic assignment operations
9+
x += 1
10+
x -= 1
11+
x *= 1
12+
x /= 1
13+
x %= 1
14+
15+
// bitwise assignment operations
16+
x &= 1
17+
x |= 1
18+
x ^= 1
19+
x <<= 1
20+
x >>= 1
21+
22+
// assignment operations with overflow
23+
x &*= 1
24+
x &+= 1
25+
x &-= 1
26+
x &<<= 1
27+
x &>>= 1
28+
29+
// pointwise assignment operations
30+
var y = SIMD4<Int>(1, 2, 3, 4)
31+
let z = SIMD4<Int>(5, 6, 7, 8)
32+
var m = y .< z
33+
y = z
34+
m .&= m
35+
m .|= m
36+
m .^= m
37+
}

0 commit comments

Comments
 (0)