> On Feb 18, 2017, at 10:14 AM, Matthew Johnson via swift-evolution 
> <swift-evolution@swift.org> 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(_:)`?

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to