Diff
Not logged in

Differences From Artifact [314aad0104b85557]:

To Artifact [09cc57fcd7c969ca]:


13 void assert_throw(ExceptionType, T, string fn=__FILE__, size_t ln=__LINE__)(lazy 13 void assert_throw(ExceptionType, T, string fn=__FILE__, size_t ln=__LINE__)(lazy 14 { 14 { 15 try 15 try 16 { t(); } 16 { t(); } 17 catch(ExceptionType) 17 catch(ExceptionType) 18 { return; } 18 { return; } 19 catch(Throwable e) 19 catch(Throwable e) 20 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.to | 20 { onAssertErrorMsg(fn, ln, msg.length ? msg : "bad exception\n > 21 onAssertErrorMsg(fn, ln, msg.length ? msg : "no execption"); | 21 onAssertErrorMsg(fn, ln, msg.length ? msg : "not thrown"); 22 } 22 } 23 23 24 /// Unittest helper that asserts an expression must not throw anything 24 /// Unittest helper that asserts an expression must not throw anything 25 25 26 auto assert_nothrow(T, string fn=__FILE__, size_t ln=__LINE__)(lazy T t, string 26 auto assert_nothrow(T, string fn=__FILE__, size_t ln=__LINE__)(lazy T t, string 27 { 27 { 28 try 28 try 29 { return t(); } 29 { return t(); } 30 catch(Throwable e) 30 catch(Throwable e) 31 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.to | 31 { onAssertErrorMsg(fn, ln, msg.length ? msg : "bad exception\n > 32 assert(false); 32 assert(false); 33 } 33 } 34 34 35 unittest 35 unittest 36 { 36 { 37 auto error = {throw new Error("hello");}; 37 auto error = {throw new Error("hello");}; 38 auto nothing = (){}; 38 auto nothing = (){};