Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw authored and github-actions[bot] committed Jul 18, 2024
1 parent 7690acc commit 2d0d95e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 66 deletions.
26 changes: 13 additions & 13 deletions Sources/InlineSnapshotTesting/AssertInlineSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ import Foundation
let message = message()
var failureMessage = """
\(message.isEmpty ? "Snapshot did not match. Difference: …" : message)
\(difference.indenting(by: 2))
"""

Expand Down Expand Up @@ -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]] = [:]
Expand Down
106 changes: 53 additions & 53 deletions Tests/InlineSnapshotTestingTests/InlineSnapshotTestingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 2d0d95e

Please sign in to comment.