-
Notifications
You must be signed in to change notification settings - Fork 98
Add protocol-level @available annotation inheritance to generated mocks #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0261032
b5cf99e
1ff56ed
d4a41e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,9 @@ | |
| init() { } | ||
| } | ||
|
|
||
| @MainActor | ||
| /// @mockable | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's strange for |
||
| @available(iOS 18.0, *) | ||
| class P1Mock: P1 { | ||
| init() { } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -208,4 +208,40 @@ | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @Fixture enum availableSendableProtocol { | ||||||||||||||||||||||||||||
| /// @mockable | ||||||||||||||||||||||||||||
| @available(iOS 18.0, *) | ||||||||||||||||||||||||||||
| public protocol Foo: Sendable { | ||||||||||||||||||||||||||||
| func bar() -> String | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+213
to
+217
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to enforce a compilation error when
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @Fixture(includesConcurrencyHelpers: true) | ||||||||||||||||||||||||||||
| enum expected { | ||||||||||||||||||||||||||||
| @available(iOS 18.0, *) | ||||||||||||||||||||||||||||
| public final class FooMock: Foo, @unchecked Sendable { | ||||||||||||||||||||||||||||
| public init() { } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| private let barState = MockoloMutex(MockoloHandlerState<Never, @Sendable () -> String>()) | ||||||||||||||||||||||||||||
| public var barCallCount: Int { | ||||||||||||||||||||||||||||
| return barState.withLock(\.callCount) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| public var barHandler: (@Sendable () -> String)? { | ||||||||||||||||||||||||||||
| get { barState.withLock(\.handler) } | ||||||||||||||||||||||||||||
| set { barState.withLock { $0.handler = newValue } } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| public func bar() -> String { | ||||||||||||||||||||||||||||
| let barHandler = barState.withLock { state in | ||||||||||||||||||||||||||||
| state.callCount += 1 | ||||||||||||||||||||||||||||
| return state.handler | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if let barHandler = barHandler { | ||||||||||||||||||||||||||||
| return barHandler() | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need a test case for protocol inheritance scenarios: @available(macOS 100.0, *)
struct Bar {}
@available(macOS 90.0, *)
protocol Foo {
}
/// @mockable
@available(macOS 100.0, *)
protocol Foo2: Foo {
var bar: Bar { get set }
} |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meaning feels a bit off and it’s redundant, so let's remove it.