Swift: Add a test for assignment exprs.

This commit is contained in:
Geoffrey White
2023-02-21 09:52:20 +00:00
parent d734982e7b
commit aaa89f7f32
3 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| assignment.swift:6:2:6:6 | ... = ... | AssignExpr | x | 1 |
| assignment.swift:33:2:33:6 | ... = ... | AssignExpr | y | z |

View File

@@ -0,0 +1,14 @@
import swift
string describe(Expr e) {
e instanceof AssignExpr and result = "AssignExpr"
}
from AssignExpr e
where
e.getLocation().getFile().getBaseName() != ""
select
e,
concat(describe(e), ", "),
concat(e.getDest().toString(), ", "),
concat(e.getSource().toString(), ", ")

View File

@@ -0,0 +1,37 @@
func test() {
var x = 0
// simple assignment
x = 1
// arithmetic assignment operations
x += 1
x -= 1
x *= 1
x /= 1
x %= 1
// bitwise assignment operations
x &= 1
x |= 1
x ^= 1
x <<= 1
x >>= 1
// assignment operations with overflow
x &*= 1
x &+= 1
x &-= 1
x &<<= 1
x &>>= 1
// pointwise assignment operations
var y = SIMD4<Int>(1, 2, 3, 4)
let z = SIMD4<Int>(5, 6, 7, 8)
var m = y .< z
y = z
m .&= m
m .|= m
m .^= m
}