From 2d0d95e5c5317d0f129fdca4255931c09a457652 Mon Sep 17 00:00:00 2001 From: mbrandonw Date: Thu, 18 Jul 2024 19:57:36 +0000 Subject: [PATCH] Run swift-format --- .../AssertInlineSnapshot.swift | 26 ++--- .../InlineSnapshotTestingTests.swift | 106 +++++++++--------- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Sources/InlineSnapshotTesting/AssertInlineSnapshot.swift b/Sources/InlineSnapshotTesting/AssertInlineSnapshot.swift index 6a3f7996b..1ca6ddf8e 100644 --- a/Sources/InlineSnapshotTesting/AssertInlineSnapshot.swift +++ b/Sources/InlineSnapshotTesting/AssertInlineSnapshot.swift @@ -167,7 +167,7 @@ import Foundation let message = message() var failureMessage = """ \(message.isEmpty ? "Snapshot did not match. Difference: …" : message) - + \(difference.indenting(by: 2)) """ @@ -362,24 +362,24 @@ public struct InlineSnapshotSyntaxDescriptor: Hashable { } } -@_spi(Internals) public struct File: Hashable { - public let path: StaticString - public static func == (lhs: Self, rhs: Self) -> Bool { + @_spi(Internals) public struct File: Hashable { + public let path: StaticString + public static func == (lhs: Self, rhs: Self) -> Bool { "\(lhs.path)" == "\(rhs.path)" } - public func hash(into hasher: inout Hasher) { + public func hash(into hasher: inout Hasher) { hasher.combine("\(self.path)") } } -@_spi(Internals) public struct InlineSnapshot: Hashable { - public var expected: String? - public var actual: String? - public var wasRecording: Bool - public var syntaxDescriptor: InlineSnapshotSyntaxDescriptor - public var function: String - public var line: UInt - public var column: UInt + @_spi(Internals) public struct InlineSnapshot: Hashable { + public var expected: String? + public var actual: String? + public var wasRecording: Bool + public var syntaxDescriptor: InlineSnapshotSyntaxDescriptor + public var function: String + public var line: UInt + public var column: UInt } @_spi(Internals) public var inlineSnapshotState: [File: [InlineSnapshot]] = [:] diff --git a/Tests/InlineSnapshotTestingTests/InlineSnapshotTestingTests.swift b/Tests/InlineSnapshotTestingTests/InlineSnapshotTestingTests.swift index 40b2154cf..c1a060b1e 100644 --- a/Tests/InlineSnapshotTestingTests/InlineSnapshotTestingTests.swift +++ b/Tests/InlineSnapshotTestingTests/InlineSnapshotTestingTests.swift @@ -287,68 +287,68 @@ final class InlineSnapshotTestingTests: XCTestCase { } } -#if canImport(Darwin) - func testRecordFailed_IncorrectExpectation() throws { - let initialInlineSnapshotState = inlineSnapshotState - defer { inlineSnapshotState = initialInlineSnapshotState } - - XCTExpectFailure { - withSnapshotTesting(record: .failed) { - assertInlineSnapshot(of: 42, as: .json) { - """ - 4 - """ + #if canImport(Darwin) + func testRecordFailed_IncorrectExpectation() throws { + let initialInlineSnapshotState = inlineSnapshotState + defer { inlineSnapshotState = initialInlineSnapshotState } + + XCTExpectFailure { + withSnapshotTesting(record: .failed) { + assertInlineSnapshot(of: 42, as: .json) { + """ + 4 + """ + } } + } issueMatcher: { + $0.compactDescription == """ + failed - Snapshot did not match. Difference: … + + @@ −1,1 +1,1 @@ + −4 + +42 + + A new snapshot was automatically recorded. + """ } - } issueMatcher: { - $0.compactDescription == """ - failed - Snapshot did not match. Difference: … - - @@ −1,1 +1,1 @@ - −4 - +42 - - A new snapshot was automatically recorded. - """ - } - XCTAssertEqual(inlineSnapshotState.count, 1) - XCTAssertEqual( - String(describing: inlineSnapshotState.keys.first!.path) - .hasSuffix("InlineSnapshotTestingTests.swift"), - true - ) - } + XCTAssertEqual(inlineSnapshotState.count, 1) + XCTAssertEqual( + String(describing: inlineSnapshotState.keys.first!.path) + .hasSuffix("InlineSnapshotTestingTests.swift"), + true + ) + } #endif -#if canImport(Darwin) - func testRecordFailed_MissingExpectation() throws { - let initialInlineSnapshotState = inlineSnapshotState - defer { inlineSnapshotState = initialInlineSnapshotState } + #if canImport(Darwin) + func testRecordFailed_MissingExpectation() throws { + let initialInlineSnapshotState = inlineSnapshotState + defer { inlineSnapshotState = initialInlineSnapshotState } - XCTExpectFailure { - withSnapshotTesting(record: .failed) { - assertInlineSnapshot(of: 42, as: .json) - } - } issueMatcher: { - $0.compactDescription == """ - failed - Automatically recorded a new snapshot. Difference: … + XCTExpectFailure { + withSnapshotTesting(record: .failed) { + assertInlineSnapshot(of: 42, as: .json) + } + } issueMatcher: { + $0.compactDescription == """ + failed - Automatically recorded a new snapshot. Difference: … - @@ −1,1 +1,1 @@ - − - +42 + @@ −1,1 +1,1 @@ + − + +42 - Re-run "testRecordFailed_MissingExpectation()" to assert against the newly-recorded snapshot. - """ - } + Re-run "testRecordFailed_MissingExpectation()" to assert against the newly-recorded snapshot. + """ + } - XCTAssertEqual(inlineSnapshotState.count, 1) - XCTAssertEqual( - String(describing: inlineSnapshotState.keys.first!.path) - .hasSuffix("InlineSnapshotTestingTests.swift"), - true - ) - } + XCTAssertEqual(inlineSnapshotState.count, 1) + XCTAssertEqual( + String(describing: inlineSnapshotState.keys.first!.path) + .hasSuffix("InlineSnapshotTestingTests.swift"), + true + ) + } #endif }