Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jul 11, 2024
1 parent 068274a commit 55aa2ff
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Sources/Dependencies/DependencyValues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,11 @@ package final class CachedValues: @unchecked Sendable {
To fix you can do one of two things:
* Conform '\(typeName(Key.self))' to the 'DependencyKey' protocol by providing \
Conform '\(typeName(Key.self))' to the 'DependencyKey' protocol by providing \
a live implementation of your dependency, and make sure that the conformance is \
linked with this current application.
* Override the implementation of '\(typeName(Key.self))' using 'withDependencies'. \
Override the implementation of '\(typeName(Key.self))' using 'withDependencies'. \
This is typically done at the entry point of your application, but can be done \
later too.
""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,8 @@ final class DependencyClientMacroTests: BaseTestCase {
"""
} expansion: {
#"""
struct Client {@available(iOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(macOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(tvOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(watchOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.")
struct Client {
@available(iOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(macOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(tvOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(watchOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.")
var fetch: (_ id: Int) throws -> String {
@storageRestrictions(initializes: _fetch)
init(initialValue) {
Expand All @@ -833,7 +834,7 @@ final class DependencyClientMacroTests: BaseTestCase {
}
@available(iOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(macOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(tvOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(watchOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") private var _fetch: (_ id: Int) throws -> String = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).fetch'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).fetch'")
throw DependenciesMacros.Unimplemented("fetch")
}
Expand Down Expand Up @@ -881,7 +882,7 @@ final class DependencyClientMacroTests: BaseTestCase {
}
@available(iOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(macOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(tvOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") @available(watchOS, deprecated: 9999, message: "This property has a method equivalent that is preferred for autocomplete via this deprecation. It is perfectly fine to use for overriding and accessing via '@Dependency'.") private var _fetch: (_ id: Int) throws -> String = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).fetch'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).fetch'")
throw DependenciesMacros.Unimplemented("fetch")
}
Expand Down Expand Up @@ -923,7 +924,7 @@ final class DependencyClientMacroTests: BaseTestCase {
}
private var _fetch: (Int) throws -> String = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).fetch'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).fetch'")
throw DependenciesMacros.Unimplemented("fetch")
}
Expand Down Expand Up @@ -973,21 +974,21 @@ final class DependencyClientMacroTests: BaseTestCase {
struct Client {
@DependencyEndpoint
var endpoint: () -> Void
var value: <#Type#>
var value: <#Type#> = Value()
init(
endpoint: @escaping () -> Void,
value: <#Type
value: <#Type#> = Value()
) {
self.endpoint = endpoint
self.value = value
self.endpoint = endpoint
self.value = value
}
init(
value: <#Type
value: <#Type#> = Value()
) {
self.value = value
}= Value()
self.value = value
}
}
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class DependencyClientTests: BaseTestCase {

XCTExpectFailure {
$0.compactDescription == """
Unimplemented: 'Client.fetch'
failed - Unimplemented: 'Client.fetch'
"""
}

Expand All @@ -30,9 +30,9 @@ final class DependencyClientTests: BaseTestCase {
XCTAssertEqual(client.fetchWithUnimplemented(), 42)
} issueMatcher: {
$0.compactDescription == """
Unimplemented …
failed - Unimplemented …
Defined at:
Defined in 'ClientWithNonThrowingEndpoint' at:
DependenciesMacrosPluginTests/DependencyClientTests.swift:\(ClientWithNonThrowingEndpoint.line + 1)
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> Void = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -69,7 +69,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> Bool = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
return false
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> Bool = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
return <#Bool#>
}
}
Expand Down Expand Up @@ -177,7 +177,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: (Int, Bool, String) -> Bool = { _, _, _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
return <#Bool#>
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () throws -> Bool = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
throw DependenciesMacros.Unimplemented("endpoint")
}
}
Expand Down Expand Up @@ -243,7 +243,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _apiRequest: @Sendable (ServerRoute.Api.Route) async throws -> (Data, URLResponse) = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).apiRequest'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).apiRequest'")
throw DependenciesMacros.Unimplemented("apiRequest")
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> () = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -308,7 +308,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> Int? = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
return nil
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> Optional<Int> = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
return nil
}
}
Expand Down Expand Up @@ -374,7 +374,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: @Sendable (Int) -> Void = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -411,7 +411,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: @Sendable (String, _ id: Int, _ progress: Float) async -> Void = { _, _, _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -448,7 +448,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: @MainActor @Sendable (_ id: Int) async -> Void = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -485,7 +485,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: @Sendable (_ id: Int) async -> Void = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -521,7 +521,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: (_ id: Int) -> Void = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -557,7 +557,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> Void = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -613,7 +613,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: (_ id: Int) -> Void = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down Expand Up @@ -662,7 +662,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _return: () throws -> Int = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).return'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).return'")
throw DependenciesMacros.Unimplemented("return")
}
"""#
Expand Down Expand Up @@ -695,7 +695,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _return: (_ id: Int) throws -> Int = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).return'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).return'")
throw DependenciesMacros.Unimplemented("return")
}
"""#
Expand Down Expand Up @@ -754,7 +754,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _doAThing: (_ value: Int) -> String = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).doAThing'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).doAThing'")
return "Hello, world"
}
}
Expand Down Expand Up @@ -793,7 +793,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _doAThing: (_ a: inout Int, _ b: Int, _ c: inout Bool) -> String = { _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).doAThing'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).doAThing'")
return "Hello, world"
}
}
Expand Down Expand Up @@ -830,7 +830,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _bar: (_ a: @autoclosure () -> Int, _ b: () -> Int, _ c: @autoclosure () -> Int) -> Void = { _, _, _ in
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).bar'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).bar'")
}
}
"""#
Expand Down Expand Up @@ -904,7 +904,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _foo: () -> Void = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).foo'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).foo'")
return {
fatalError()
}()
Expand All @@ -923,7 +923,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _bar: () -> String = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).bar'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).bar'")
return {
fatalError("Goodbye")
}()
Expand Down Expand Up @@ -967,12 +967,12 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _foo: () throws -> Void = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).foo'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).foo'")
throw DependenciesMacros.Unimplemented("foo")
} {
willSet {
print("!")
}
willSet {
print("!")
}
}
}
"""#
Expand Down Expand Up @@ -1004,7 +1004,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
}
private var _endpoint: () -> Void = {
XCTestDynamicOverlay.XCTFail("Unimplemented: '\(Self.self).endpoint'")
IssueReporting.reportIssue("Unimplemented: '\(Self.self).endpoint'")
}
}
"""#
Expand Down
6 changes: 3 additions & 3 deletions Tests/DependenciesTests/AssertTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ final class AssertTests: XCTestCase {
XCTExpectFailure {
assert(false, "Must be true")
} issueMatcher: {
$0.compactDescription == "Must be true"
$0.compactDescription == "failed - Must be true"
}
XCTExpectFailure {
assertionFailure("Failure")
} issueMatcher: {
$0.compactDescription == "Failure"
$0.compactDescription == "failed - Failure"
}
XCTExpectFailure {
precondition(false)
}
XCTExpectFailure {
precondition(false, "Must be true")
} issueMatcher: {
$0.compactDescription == "Must be true"
$0.compactDescription == "failed - Must be true"
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependenciesTests/DependencyEndpointTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
client.endpoint()
} issueMatcher: {
$0.compactDescription == """
Unimplemented: 'Client.endpoint'
failed - Unimplemented: 'Client.endpoint'
"""
}
}
Expand Down
Loading

0 comments on commit 55aa2ff

Please sign in to comment.