Swift: Add CFG test cases for #available.

This commit is contained in:
Geoffrey White
2023-02-09 11:31:41 +00:00
parent 224bc9381a
commit 38f4f65fc0
2 changed files with 49 additions and 0 deletions

View File

@@ -6325,3 +6325,26 @@ cfg.swift:
# 493| 13
#-----| -> exit testIfConfig() (normal)
# 496| enter testAvailable()
#-----| -> testAvailable()
# 496| testAvailable()
#-----| -> x
# 497| var ... = ...
#-----| -> x
# 497| x
#-----| -> if ... then { ... }
# 497| x
#-----| match -> 0
# 497| 0
#-----| -> var ... = ...
# 499| if ... then { ... }
#-----| -> StmtCondition
# 499| StmtCondition

View File

@@ -492,3 +492,29 @@ func testIfConfig() {
13
}
func testAvailable() -> Int {
var x = 0;
if #available(macOS 10, *) {
x += 1
}
if #available(macOS 10.13, *) {
x += 1
}
if #unavailable(iOS 10, watchOS 10, macOS 10) {
x += 1
}
guard #available(macOS 12, *) else {
x += 1
}
if #available(macOS 12, *), #available(iOS 12, *) {
x += 1
}
return x
}