Skip to content

Commit 38f4f65

Browse files
committed
Swift: Add CFG test cases for #available.
1 parent 224bc93 commit 38f4f65

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

swift/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6325,3 +6325,26 @@ cfg.swift:
63256325

63266326
# 493| 13
63276327
#-----| -> exit testIfConfig() (normal)
6328+
6329+
# 496| enter testAvailable()
6330+
#-----| -> testAvailable()
6331+
6332+
# 496| testAvailable()
6333+
#-----| -> x
6334+
6335+
# 497| var ... = ...
6336+
#-----| -> x
6337+
6338+
# 497| x
6339+
#-----| -> if ... then { ... }
6340+
6341+
# 497| x
6342+
#-----| match -> 0
6343+
6344+
# 497| 0
6345+
#-----| -> var ... = ...
6346+
6347+
# 499| if ... then { ... }
6348+
#-----| -> StmtCondition
6349+
6350+
# 499| StmtCondition

swift/ql/test/library-tests/controlflow/graph/cfg.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,29 @@ func testIfConfig() {
492492

493493
13
494494
}
495+
496+
func testAvailable() -> Int {
497+
var x = 0;
498+
499+
if #available(macOS 10, *) {
500+
x += 1
501+
}
502+
503+
if #available(macOS 10.13, *) {
504+
x += 1
505+
}
506+
507+
if #unavailable(iOS 10, watchOS 10, macOS 10) {
508+
x += 1
509+
}
510+
511+
guard #available(macOS 12, *) else {
512+
x += 1
513+
}
514+
515+
if #available(macOS 12, *), #available(iOS 12, *) {
516+
x += 1
517+
}
518+
519+
return x
520+
}

0 commit comments

Comments
 (0)