Skip to content

Commit

Permalink
fix(build): update code to build for xcode 15.3 beta 2 (#3506)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisabhash authored Feb 12, 2024
1 parent ce67d1c commit 97d3da0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
/// - fail: error handler
/// - Returns: optional result
func attempt<T>(_ expression: @autoclosure () throws -> T,
fail: @autoclosure () -> ((Swift.Error) -> Void) = { _ in }) -> T? {
fail: @autoclosure () -> ((Swift.Error) -> Void)) -> T? {
do {
return try expression()
} catch {
Expand All @@ -29,7 +29,7 @@ func attempt<T>(_ expression: @autoclosure () throws -> T,
/// - Returns: success
@discardableResult
func attempt(_ expression: @autoclosure () throws -> Void,
fail: @autoclosure () -> ((Swift.Error) -> Void) = { _ in }) -> Bool {
fail: @autoclosure () -> ((Swift.Error) -> Void)) -> Bool {
do {
try expression()
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ class AttemptTests: XCTestCase {
}

func testAttemptNoFailClosureNoThrow() throws {
let result = attempt(try work1(number: badNumber))
let result = attempt(try work1(number: badNumber),
fail: { error in })
XCTAssertNil(result)
}

func testAttemptNoFailClosureThrow() throws {
let result = attempt(try work2(number: badNumber))
let result = attempt(try work2(number: badNumber),
fail: { error in })
XCTAssertEqual(false, result)
}

Expand Down

0 comments on commit 97d3da0

Please sign in to comment.