Sent from my iPad
On Feb 19, 2017, at 12:21 AM, Brent Royal-Gordon <[email protected]> wrote: >> On Feb 18, 2017, at 10:14 AM, Matthew Johnson via swift-evolution >> <[email protected]> wrote: >> >> When writing unit tests sometimes it is necessary to artificially elevate a >> member to `internal` in order to make it visible to unit tests where it >> could otherwise be `private` or `fileprivate`. We could introduce an >> `@testable` attribute that could be applied anywhere an access modifier is >> used. This attribute would elevate the access modifier to `internal` when >> the module is imported using the `@testable import MyModule` syntax in a >> test suite. > > extension MyModel { > public func load(fromJSON jsonData: Data) throws { > ... > } > > private func parse(_ json: Data) -> Any { … } > } > > extension MyModel { > public func load(fromPropertyList plistData: Data) throws { > … > } > > private func parse(_ plist: Data) -> Any { … } > } > > What happens when you try to test `MyModel.parse(_:)`? With what I suggested you would not be able to unless you change the declarations to `@testable private`. With Robert's alternative this would already be testable. > > -- > Brent Royal-Gordon > Architechies > _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
