-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathbasic.swift
33 lines (27 loc) · 910 Bytes
/
basic.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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