Differences From Artifact [bb5afea9b7b1423d]:
- File        
tricks/test.d
- 2010-11-09 05:19:20 - part of checkin [8de5b49cdf] on branch trunk - split tricks module into a separate package. (user: kinaba) [annotate]
 
 
To Artifact [de7560f1ecccee67]:
- File        
tricks/test.d
- 2010-11-09 06:19:11 - part of checkin [d78d700f7a] on branch trunk - tenuki REPL bug-fix (now we can continue using REPL after a syntax error) and file interpreter mode. (user: kinaba) [annotate]
 
 
     6      6    */
     7      7   module tricks.test;
     8      8   import std.conv : to;
     9      9   import core.exception;
    10     10   
    11     11   /// Unittest helper that asserts an expression must throw something
    12     12   
    13         -void assert_throw(ExceptionType, T, string fn=__FILE__, int ln=__LINE__)(lazy T t, string msg="")
           13  +void assert_throw(ExceptionType, T, string fn=__FILE__, size_t ln=__LINE__)(lazy T t, string msg="")
    14     14   {
    15     15    try
    16     16     { t(); }
    17     17    catch(ExceptionType)
    18     18     { return; }
    19     19    catch(Throwable e)
    20     20     { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.toString()~"]"); }
    21     21    onAssertErrorMsg(fn, ln, msg.length ? msg : "no execption");
    22     22   }
    23     23   
    24     24   /// Unittest helper that asserts an expression must not throw anything
    25     25   
    26         -auto assert_nothrow(T, string fn=__FILE__, int ln=__LINE__)(lazy T t, string msg="")
           26  +auto assert_nothrow(T, string fn=__FILE__, size_t ln=__LINE__)(lazy T t, string msg="")
    27     27   {
    28     28    try
    29     29     { return t(); }
    30     30    catch(Throwable e)
    31     31     { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.toString()~"]"); }
    32     32    assert(false);
    33     33   }
................................................................................
    48     48    assert_throw!AssertError( assert_throw!AssertError(error()) );
    49     49   }
    50     50   
    51     51   /// Unittest helpers asserting two values are in some relation ==, !=, <, <=, >, >=
    52     52   
    53     53   template assertOp(string op)
    54     54   {
    55         - void assertOp(A, B, string fn=__FILE__, int ln=__LINE__)(A a, B b, string msg="")
           55  + void assertOp(A, B, string fn=__FILE__, size_t ln=__LINE__)(A a, B b, string msg="")
    56     56    {
    57     57     try
    58     58      { if( mixin("a"~op~"b") ) return; }
    59     59     catch(Throwable e)
    60     60      { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.toString()~"]"); }
    61     61     onAssertErrorMsg(fn, ln, msg.length ? msg : to!string(a)~" !"~op~to!string(b));
    62     62    }