Skip to content

Commit f58c62c

Browse files
committed
[test] Use %refactor-check-compiles in more places
Update a bunch of async refactoring tests to use %refactor-check-compiles in more cases.
1 parent 2887f40 commit f58c62c

File tree

8 files changed

+1573
-1507
lines changed

8 files changed

+1573
-1507
lines changed

test/refactoring/ConvertAsync/basic.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ typealias NestedAliasCallback = SomeCallback
1414
// 1. Check various functions for having/not having async alternatives
1515

1616
// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+4):1 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
17-
// RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+3):6 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
18-
// RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):12 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
19-
// RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):20 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
17+
// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+3):6 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
18+
// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):12 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
19+
// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):20 | %FileCheck -check-prefix=ASYNC-SIMPLE %s
2020
func simple(/*cs*/ completion: @escaping (String) -> Void /*ce*/) { }
2121
// ASYNC-SIMPLE: basic.swift [[# @LINE-1]]:1 -> [[# @LINE-1]]:1
2222
// ASYNC-SIMPLE-NEXT: @available(*, renamed: "simple()")
@@ -113,7 +113,7 @@ func errorOnly(completion: @escaping (Error?) -> Void) { }
113113
// ASYNC-ERRORONLY-NEXT: }
114114
// ASYNC-ERRORONLY: func errorOnly() async throws { }
115115

116-
// RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ASYNC-ERRORNONOPTIONALRESULT %s
116+
// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ASYNC-ERRORNONOPTIONALRESULT %s
117117
func errorNonOptionalResult(completion: @escaping (String, Error?) -> Void) { }
118118
// ASYNC-ERRORNONOPTIONALRESULT: {
119119
// ASYNC-ERRORNONOPTIONALRESULT-NEXT: Task {
@@ -253,7 +253,7 @@ func mixed(_ completion: @escaping (String?, Int) -> Void) { }
253253
// MIXED-NEXT: }
254254
// MIXED: func mixed() async -> (String?, Int) { }
255255

256-
// RUN: %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MIXED-OPTIONAL-ERROR %s
256+
// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MIXED-OPTIONAL-ERROR %s
257257
func mixedOptionalError(_ completion: @escaping (String?, Int, Error?) -> Void) { }
258258
// MIXED-OPTIONAL-ERROR: {
259259
// MIXED-OPTIONAL-ERROR-NEXT: Task {
@@ -377,7 +377,7 @@ protocol MyProtocol {
377377
}
378378

379379
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
380-
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-COMPLETION %s
380+
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-COMPLETION %s
381381
func nonCompletion(a: Int) { }
382382
// NON-COMPLETION: func nonCompletion(a: Int) async { }
383383

@@ -387,27 +387,27 @@ func nonEscapingCompletion(completion: (Int) -> Void) { }
387387
// NON-ESCAPING-COMPLETION: func nonEscapingCompletion(completion: (Int) -> Void) async { }
388388

389389
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
390-
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MULTIPLE-RESULTS %s
390+
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MULTIPLE-RESULTS %s
391391
func multipleResults(completion: @escaping (Result<String, Error>, Result<String, Error>) -> Void) { }
392392
// MULTIPLE-RESULTS: func multipleResults(completion: @escaping (Result<String, Error>, Result<String, Error>) -> Void) async { }
393393

394394
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
395-
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-VOID %s
395+
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=NON-VOID %s
396396
func nonVoid(completion: @escaping (String) -> Void) -> Int { return 0 }
397397
// NON-VOID: func nonVoid(completion: @escaping (String) -> Void) async -> Int { return 0 }
398398

399399
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
400-
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=COMPLETION-NON-VOID %s
400+
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=COMPLETION-NON-VOID %s
401401
func completionNonVoid(completion: @escaping (String) -> Int) -> Void { }
402402
// COMPLETION-NON-VOID: func completionNonVoid(completion: @escaping (String) -> Int) async -> Void { }
403403

404404
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
405-
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ALREADY-THROWS %s
405+
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=ALREADY-THROWS %s
406406
func alreadyThrows(completion: @escaping (String) -> Void) throws { }
407407
// ALREADY-THROWS: func alreadyThrows(completion: @escaping (String) -> Void) async throws { }
408408

409409
// RUN: not %refactor -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1
410-
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=AUTO-CLOSURE %s
410+
// RUN: %refactor-check-compiles -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=AUTO-CLOSURE %s
411411
func noParamAutoclosure(completion: @escaping @autoclosure () -> Void) { }
412412
// AUTO-CLOSURE: func noParamAutoclosure(completion: @escaping @autoclosure () -> Void) async { }
413413

@@ -640,13 +640,17 @@ func testSkipAssign() {
640640
// SKIP-ASSIGN-FUNC-NEXT: print("assigned"){{$}}
641641
// SKIP-ASSIGN-FUNC-NEXT: }{{$}}
642642

643+
// Same as noParamAutoclosure defined above, but used just for the test below.
644+
// This avoids a compiler error when converting noParamAutoclosure to async.
645+
func noParamAutoclosure2(completion: @escaping @autoclosure () -> Void) {}
646+
643647
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefixes=SKIP-AUTOCLOSURE-FUNC %s
644648
func testSkipAutoclosure() {
645649
// RUN: not %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):3
646-
noParamAutoclosure(completion: print("autoclosure"))
650+
noParamAutoclosure2(completion: print("autoclosure"))
647651
}
648652
// SKIP-AUTOCLOSURE-FUNC: {{^}}func testSkipAutoclosure() async {
649-
// SKIP-AUTOCLOSURE-FUNC: noParamAutoclosure(completion: print("autoclosure")){{$}}
653+
// SKIP-AUTOCLOSURE-FUNC: noParamAutoclosure2(completion: print("autoclosure")){{$}}
650654

651655
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=EMPTY-CAPTURE %s
652656
func testEmptyCapture() {

0 commit comments

Comments
 (0)