Swift: Add tests for LogicalOperaion.qll.

This commit is contained in:
Geoffrey White
2022-06-27 17:39:48 +01:00
parent c72377cf2c
commit 63376da90f
3 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import swift
string describe(LogicalOperation e) {
(e instanceof BinaryLogicalOperation and result = "BinaryLogicalExpr") or
(e instanceof LogicalAndExpr and result = "LogicalAndExpr") or
(e instanceof LogicalOrExpr and result = "LogicalOrExpr") or
(e instanceof UnaryLogicalOperation and result = "UnaryLogicalOperation") or
(e instanceof NotExpr and result = "NotExpr")
}
from LogicalOperation e
select e, concat(describe(e), ", ")

View File

@@ -0,0 +1,8 @@
func test(a: Bool, b: Bool, c: Bool) {
// logical operations
if (a && b) {}
if (a || b) {}
if (!a) {}
if (!((a && b) || c)) {}
}