-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support/tests for Swift 5.5 concurrency syntax.
- `for await` and `for try await` loops - `async` closure expressions - Improve grouping for `async throws` functions/closures - `await` expressions - `async let` declarations
- Loading branch information
Showing
9 changed files
with
507 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import SwiftFormatConfiguration | ||
|
||
final class AwaitExprTests: PrettyPrintTestCase { | ||
func testBasicAwaits() { | ||
let input = | ||
""" | ||
let a = await asynchronousFunction() | ||
let b = await longerAsynchronousFunction() | ||
let c = await evenLongerAndLongerAsynchronousFunction() | ||
""" | ||
|
||
let expected = | ||
""" | ||
let a = await asynchronousFunction() | ||
let b = | ||
await longerAsynchronousFunction() | ||
let c = | ||
await | ||
evenLongerAndLongerAsynchronousFunction() | ||
""" | ||
|
||
assertPrettyPrintEqual(input: input, expected: expected, linelength: 36) | ||
} | ||
|
||
func testAwaitKeywordBreaking() { | ||
let input = | ||
""" | ||
let aVeryLongArgumentName = await foo.bar() | ||
let aVeryLongArgumentName = await | ||
foo.bar() | ||
let abc = await foo.baz().quxxe(a, b, c).bar() | ||
let abc = await foo | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = await [1, 2, 3, 4, 5, 6, 7].baz().quxxe(a, b, c).bar() | ||
let abc = await [1, 2, 3, 4, 5, 6, 7] | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = await foo.baz().quxxe(a, b, c).bar[0] | ||
let abc = await foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
let abc = await | ||
foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
""" | ||
|
||
let expected = | ||
""" | ||
let aVeryLongArgumentName = | ||
await foo.bar() | ||
let aVeryLongArgumentName = | ||
await foo.bar() | ||
let abc = await foo.baz().quxxe(a, b, c) | ||
.bar() | ||
let abc = | ||
await foo | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = await [1, 2, 3, 4, 5, 6, 7] | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = await [1, 2, 3, 4, 5, 6, 7] | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = await foo.baz().quxxe(a, b, c) | ||
.bar[0] | ||
let abc = | ||
await foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
let abc = | ||
await foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
""" | ||
|
||
assertPrettyPrintEqual(input: input, expected: expected, linelength: 42) | ||
} | ||
|
||
func testTryAwaitKeywordBreaking() { | ||
let input = | ||
""" | ||
let aVeryLongArgumentName = try await foo.bar() | ||
let aVeryLongArgumentName = try await | ||
foo.bar() | ||
let abc = try await foo.baz().quxxe(a, b, c).bar() | ||
let abc = try await foo | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = try await [1, 2, 3, 4, 5, 6, 7].baz().quxxe(a, b, c).bar() | ||
let abc = try await [1, 2, 3, 4, 5, 6, 7] | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = try await foo.baz().quxxe(a, b, c).bar[0] | ||
let abc = try await foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
let abc = try await | ||
foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
let abc = try await thisIsASuperblyExtremelyVeryLongFunctionName() | ||
""" | ||
|
||
let expected = | ||
""" | ||
let aVeryLongArgumentName = | ||
try await foo.bar() | ||
let aVeryLongArgumentName = | ||
try await foo.bar() | ||
let abc = try await foo.baz().quxxe(a, b, c) | ||
.bar() | ||
let abc = | ||
try await foo | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = try await [1, 2, 3, 4, 5, 6, 7] | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = try await [1, 2, 3, 4, 5, 6, 7] | ||
.baz().quxxe(a, b, c).bar() | ||
let abc = try await foo.baz().quxxe(a, b, c) | ||
.bar[0] | ||
let abc = | ||
try await foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
let abc = | ||
try await foo | ||
.baz().quxxe(a, b, c).bar[0] | ||
let abc = | ||
try await | ||
thisIsASuperblyExtremelyVeryLongFunctionName() | ||
""" | ||
|
||
assertPrettyPrintEqual(input: input, expected: expected, linelength: 46) | ||
} | ||
} |
Oops, something went wrong.