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:
@@ -262,6 +262,20 @@ func testConvertToTernaryExpr() {
|
||||
}
|
||||
}
|
||||
|
||||
func testConvertToGuardExpr(idxOpt: Int?) {
|
||||
if let idx = idxOpt {
|
||||
print(idx)
|
||||
}
|
||||
}
|
||||
|
||||
func testConvertToIfLetExpr(idxOpt: Int?) {
|
||||
guard let idx = idxOpt else {
|
||||
return
|
||||
}
|
||||
print(idx)
|
||||
}
|
||||
|
||||
|
||||
// RUN: %refactor -source-filename %s -pos=2:1 -end-pos=5:13 | %FileCheck %s -check-prefix=CHECK1
|
||||
// RUN: %refactor -source-filename %s -pos=3:1 -end-pos=5:13 | %FileCheck %s -check-prefix=CHECK1
|
||||
// RUN: %refactor -source-filename %s -pos=4:1 -end-pos=5:13 | %FileCheck %s -check-prefix=CHECK1
|
||||
@@ -355,6 +369,10 @@ func testConvertToTernaryExpr() {
|
||||
|
||||
// RUN: %refactor -source-filename %s -pos=257:3 -end-pos=262:4 | %FileCheck %s -check-prefix=CHECK-CONVERT-TO-TERNARY-EXPRESSEXPRESSION
|
||||
|
||||
// RUN: %refactor -source-filename %s -pos=266:3 -end-pos=268:4 | %FileCheck %s -check-prefix=CHECK-CONVERT-TO-GUARD-EXPRESSION
|
||||
|
||||
// RUN: %refactor -source-filename %s -pos=272:3 -end-pos=275:13 | %FileCheck %s -check-prefix=CHECK-CONVERT-TO-IFLET-EXPRESSION
|
||||
|
||||
// CHECK1: Action begins
|
||||
// CHECK1-NEXT: Extract Method
|
||||
// CHECK1-NEXT: Action ends
|
||||
@@ -401,3 +419,7 @@ func testConvertToTernaryExpr() {
|
||||
// CHECK-EXPAND-TERNARY-EXPRESSEXPRESSION: Expand Ternary Expression
|
||||
|
||||
// CHECK-CONVERT-TO-TERNARY-EXPRESSEXPRESSION: Convert To Ternary Expression
|
||||
|
||||
// CHECK-CONVERT-TO-GUARD-EXPRESSION: Convert To Guard Expression
|
||||
|
||||
// CHECK-CONVERT-TO-IFLET-EXPRESSION: Convert To IfLet Expression
|
||||
Reference in New Issue
Block a user