<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Dec 7, 2015 at 9:03 AM, David Hart via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="auto"><div>But then you can't unit-test that the function fails on those parameters.</div></div></blockquote><div><br></div><div>Yes you can. Maybe not with the current XCTest, but there's nothing that prevents unit-testing traps in principle. The standard library is already doing that. See test/1_stdlib/ArrayTraps.swift.gyb for some examples:</div><div><br></div><div>ArrayTraps.test("downcast1")</div><div> .skip(.Custom(</div><div> { _isFastAssertConfiguration() },</div><div> reason: "this trap is not guaranteed to happen in -Ounchecked"))</div><div> .code {</div><div> let ba: [Base] = [ Derived(), Base() ]</div><div> let da = ba as! [Derived]</div><div> let d0 = da[0]</div><div> expectCrashLater()</div><div> da[1]</div><div>} </div><div><br></div><div>Dmitri</div></div><div><br></div>-- <br><div class="gmail_signature">main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>>*/</div>
</div></div>