mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SR-5744 Refactoring action to convert if-let to guard-let and vice versa
This commit is contained in:
33
test/refactoring/ConvertToIfLet/basic.swift
Normal file
33
test/refactoring/ConvertToIfLet/basic.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
func foo(idxOpt: Int?) {
|
||||
guard let idx = idxOpt else {
|
||||
return
|
||||
}
|
||||
print(idx)
|
||||
}
|
||||
|
||||
func bar(fooOpt: Int?) {
|
||||
guard let foo = fooOpt else {
|
||||
return
|
||||
}
|
||||
let incrementedFoo = foo + 1
|
||||
print(incrementedFoo)
|
||||
}
|
||||
|
||||
func fooBar(idxOpt: Int?) {
|
||||
guard let idx = idxOpt else {
|
||||
print("nil")
|
||||
return
|
||||
}
|
||||
print(idx)
|
||||
}
|
||||
|
||||
// RUN: rm -rf %t.result && mkdir -p %t.result
|
||||
|
||||
// RUN: %refactor -convert-to-iflet -source-filename %s -pos=2:3 -end-pos=5:13 > %t.result/L2-3.swift
|
||||
// RUN: diff -u %S/Outputs/basic/L2-3.swift.expected %t.result/L2-3.swift
|
||||
|
||||
// RUN: %refactor -convert-to-iflet -source-filename %s -pos=9:3 -end-pos=13:24 > %t.result/L9-3.swift
|
||||
// RUN: diff -u %S/Outputs/basic/L9-3.swift.expected %t.result/L9-3.swift
|
||||
|
||||
// RUN: %refactor -convert-to-iflet -source-filename %s -pos=17:3 -end-pos=21:13 > %t.result/L17-3.swift
|
||||
// RUN: diff -u %S/Outputs/basic/L17-3.swift.expected %t.result/L17-3.swift
|
||||
Reference in New Issue
Block a user