<div dir="ltr">To be specific, are you suggesting<div><br></div><div>func XCTAssertThrowsError&lt;E: ErrorType where E: Equatable&gt;(@autoclosure expr: () throws -&gt; Void, _ error: E)</div><div><br></div><div>?</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob Bandes-Storch<br></div></div></div></div>
<br><div class="gmail_quote">On Tue, Jan 12, 2016 at 8:30 AM, Joe Masilotti via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I agree that being able to assert what type of error is thrown should be considered for this proposal. As mentioned in the previous message, a lot of Swift core classes have untested code paths due to error throwing and catching.<div><br></div><div>I think that you should be able to assert which error is thrown without having to deal with a closure. For example, instead of:</div><div><br></div><div><div>XCTAssertThrowsError(try foo(), { error</div><div>    if error != MyError.Foo {</div><div>        XCTFail(“MyError.Foo was not thrown”)</div><div>    }</div><div>}</div></div><div><br></div><div>I propose:</div><div><br></div><div>XCTAssertThrowsError(try foo(), MyError.Foo)</div><div><br></div><div>This removes more boiler plate code for the developer to write, the initial goal of this proposal. Also, the original proposed approach requires the developer to remember to fail if the error wasn’t the correct type. Forgetting to explicitly fail might not actually test anything.<br></div><div><br></div><div>Joe Masilotti</div><div>Masilotti.com</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=P-2BsYbBZHRBuLDBJaL4DIKDNfkkjpROowTyRAObV11qxwxAa4-2FzJcoWsL7MjXYvmuW1KvzhyTdr1Qhhv1wPnqEZOTDSqrwJgM6p6-2F6EmJgaSCZ3Lo5GIEX-2FUiZabnI506d4XiDHpcCy7c1FeZGQyQ6Kt7SsQZVkdw4ITUurD29ydhWgzi-2F0-2B0UE7ns2blzuPUXlJiSvvfPiwSlq-2BR-2BzGBuuM88k-2BS8jHIglIrGCKGw3w-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div>