[swift-evolution] Testing access level, final, and static

Dave Abrahams dabrahams at apple.com
Wed Sep 21 10:53:53 CDT 2016


on Wed Sep 21 2016, Benjamin Spratling <swift-evolution at swift.org> wrote:

> Howdy,
> As I understand it, In Swift 3, a lack of encapsulation is testable,
> but specific keywords to protect a designed encapsulation can’t be
> introspected, and thus encapsulation is fragile, i.e. not protectable
> by unit tests.
>
> For instance, we can write unit-tests that determine if a member's
> access level is at least a given level.  (by writing a test which
> accesses it at that level.)  However, we cannot test that it is less
> than, or exactly at a specific level.  

You can certainly write tests that only succeed when compilation fails.
Another option would be to use SourceKit to get a programmatic
representation of the code and check that.

HTH,

-- 
-Dave



More information about the swift-evolution mailing list