マクロ
expect(_:sourceLocation:performing:
throws:)
  廃止  
式が常に何らかの条件に一致するエラーを throw することを確認します。
Swift 6.0+ Xcode 16.0+
@discardableResult @freestanding(expression)
macro expect<R>(
_ comment: @autoclosure () -> Comment? = nil,
sourceLocation: SourceLocation = #_sourceLocation,
performing expression: () async throws -> R,
throws errorMatcher: (any Error) async throws -> Bool
) -> (any Error)?
let error = #expect(throws: FoodTruckError.self) {
...
}
#expect(error?.napkinCount == 0)
以下も見よ
エラーが throw されたか確認する
Swift コード内のエラーのテスト
コードがあなたの期待どおりにエラーを処理することを確認します。
macro expect<E, R>(throws: E.Type, @autoclosure () -> Comment?, sourceLocation: SourceLocation, performing: () async throws -> R) -> E?
式が常に与えられた型のエラーを throw することを確認します。
macro expect<E, R>(throws: E, @autoclosure () -> Comment?, sourceLocation: SourceLocation, performing: () async throws -> R) -> E?
式が常に特定のエラーを throw することを確認します。
macro require<E, R>(throws: E.Type, @autoclosure () -> Comment?, sourceLocation: SourceLocation, performing: () async throws -> R) -> E
式が常に与えられた型のエラーを throw することを確認し、そうでない場合はエラーを throw します。
macro require<E, R>(throws: E, @autoclosure () -> Comment?, sourceLocation: SourceLocation, performing: () async throws -> R) -> E
macro require<R>(@autoclosure () -> Comment?, sourceLocation: SourceLocation, performing: () async throws -> R, throws: (any Error) async throws -> Bool) -> any Error
式が常に何らかの条件に一致するエラーを throw することを確認し、そうでない場合はエラーを throw します。
  廃止  
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ
トップへ