|
| 1 | +import Spyable |
| 2 | + |
| 3 | +// MARK: - Open |
| 4 | + |
| 5 | +// Only classes and overridable class members can be declared 'open'. |
| 6 | + |
| 7 | +// MARK: - Public |
| 8 | + |
| 9 | +@Spyable |
| 10 | +public protocol PublicServiceProtocol { |
| 11 | + var name: String { get } |
| 12 | + var anyProtocol: any Codable { get set } |
| 13 | + var secondName: String? { get } |
| 14 | + var address: String! { get } |
| 15 | + var added: () -> Void { get set } |
| 16 | + var removed: (() -> Void)? { get set } |
| 17 | + |
| 18 | + func initialize(name: String, _ secondName: String?) |
| 19 | + func fetchConfig(arg: UInt8) async throws -> [String: String] |
| 20 | + func fetchData(_ name: (String, count: Int)) async -> (() -> Void) |
| 21 | + func save(name: any Codable, surname: any Codable) |
| 22 | + func insert(name: (any Codable)?, surname: (any Codable)?) |
| 23 | + func append(name: (any Codable) -> (any Codable)?) |
| 24 | + func get() async throws -> any Codable |
| 25 | + func read() -> String! |
| 26 | + func wrapDataInArray<T>(_ data: T) -> [T] |
| 27 | +} |
| 28 | + |
| 29 | +func testPublicServiceProtocol() { |
| 30 | + let spy = PublicServiceProtocolSpy() |
| 31 | + |
| 32 | + spy.name = "Spy" |
| 33 | +} |
| 34 | + |
| 35 | +// MARK: - Package |
| 36 | + |
| 37 | +@Spyable |
| 38 | +package protocol PackageServiceProtocol { |
| 39 | + var name: String { get } |
| 40 | + var anyProtocol: any Codable { get set } |
| 41 | + var secondName: String? { get } |
| 42 | + var address: String! { get } |
| 43 | + var added: () -> Void { get set } |
| 44 | + var removed: (() -> Void)? { get set } |
| 45 | + |
| 46 | + func initialize(name: String, _ secondName: String?) |
| 47 | + func fetchConfig(arg: UInt8) async throws -> [String: String] |
| 48 | + func fetchData(_ name: (String, count: Int)) async -> (() -> Void) |
| 49 | + func save(name: any Codable, surname: any Codable) |
| 50 | + func insert(name: (any Codable)?, surname: (any Codable)?) |
| 51 | + func append(name: (any Codable) -> (any Codable)?) |
| 52 | + func get() async throws -> any Codable |
| 53 | + func read() -> String! |
| 54 | + func wrapDataInArray<T>(_ data: T) -> [T] |
| 55 | +} |
| 56 | + |
| 57 | +func testPackageServiceProtocol() { |
| 58 | + let spy = PackageServiceProtocolSpy() |
| 59 | + |
| 60 | + spy.name = "Spy" |
| 61 | +} |
| 62 | + |
| 63 | +// MARK: - Internal |
| 64 | + |
| 65 | +@Spyable |
| 66 | +internal protocol InternalServiceProtocol { |
| 67 | + var name: String { get } |
| 68 | + var anyProtocol: any Codable { get set } |
| 69 | + var secondName: String? { get } |
| 70 | + var address: String! { get } |
| 71 | + var added: () -> Void { get set } |
| 72 | + var removed: (() -> Void)? { get set } |
| 73 | + |
| 74 | + func initialize(name: String, _ secondName: String?) |
| 75 | + func fetchConfig(arg: UInt8) async throws -> [String: String] |
| 76 | + func fetchData(_ name: (String, count: Int)) async -> (() -> Void) |
| 77 | + func save(name: any Codable, surname: any Codable) |
| 78 | + func insert(name: (any Codable)?, surname: (any Codable)?) |
| 79 | + func append(name: (any Codable) -> (any Codable)?) |
| 80 | + func get() async throws -> any Codable |
| 81 | + func read() -> String! |
| 82 | + func wrapDataInArray<T>(_ data: T) -> [T] |
| 83 | +} |
| 84 | + |
| 85 | +func testInternalServiceProtocol() { |
| 86 | + let spy = InternalServiceProtocolSpy() |
| 87 | + |
| 88 | + spy.name = "Spy" |
| 89 | +} |
| 90 | + |
| 91 | +// MARK: - Fileprivate |
| 92 | + |
| 93 | +@Spyable |
| 94 | +// swiftformat:disable:next |
| 95 | +private protocol FileprivateServiceProtocol { |
| 96 | + var name: String { get } |
| 97 | + var anyProtocol: any Codable { get set } |
| 98 | + var secondName: String? { get } |
| 99 | + var address: String! { get } |
| 100 | + var added: () -> Void { get set } |
| 101 | + var removed: (() -> Void)? { get set } |
| 102 | + |
| 103 | + func initialize(name: String, _ secondName: String?) |
| 104 | + func fetchConfig(arg: UInt8) async throws -> [String: String] |
| 105 | + func fetchData(_ name: (String, count: Int)) async -> (() -> Void) |
| 106 | + func save(name: any Codable, surname: any Codable) |
| 107 | + func insert(name: (any Codable)?, surname: (any Codable)?) |
| 108 | + func append(name: (any Codable) -> (any Codable)?) |
| 109 | + func get() async throws -> any Codable |
| 110 | + func read() -> String! |
| 111 | + func wrapDataInArray<T>(_ data: T) -> [T] |
| 112 | +} |
| 113 | + |
| 114 | +func testFileprivateServiceProtocol() { |
| 115 | + let spy = FileprivateServiceProtocolSpy() |
| 116 | + |
| 117 | + spy.name = "Spy" |
| 118 | +} |
| 119 | + |
| 120 | +// MARK: - Private |
| 121 | + |
| 122 | +@Spyable |
| 123 | +private protocol PrivateServiceProtocol { |
| 124 | + var name: String { get } |
| 125 | + var anyProtocol: any Codable { get set } |
| 126 | + var secondName: String? { get } |
| 127 | + var address: String! { get } |
| 128 | + var added: () -> Void { get set } |
| 129 | + var removed: (() -> Void)? { get set } |
| 130 | + |
| 131 | + func initialize(name: String, _ secondName: String?) |
| 132 | + func fetchConfig(arg: UInt8) async throws -> [String: String] |
| 133 | + func fetchData(_ name: (String, count: Int)) async -> (() -> Void) |
| 134 | + func save(name: any Codable, surname: any Codable) |
| 135 | + func insert(name: (any Codable)?, surname: (any Codable)?) |
| 136 | + func append(name: (any Codable) -> (any Codable)?) |
| 137 | + func get() async throws -> any Codable |
| 138 | + func read() -> String! |
| 139 | + func wrapDataInArray<T>(_ data: T) -> [T] |
| 140 | +} |
| 141 | + |
| 142 | +func testPrivateServiceProtocol() { |
| 143 | + let spy = PrivateServiceProtocolSpy() |
| 144 | + |
| 145 | + spy.name = "Spy" |
| 146 | +} |
0 commit comments