Changeset 90

Show
Ignore:
Timestamp:
02/05/10 12:48:47 (2 years ago)
Author:
mgalloy
Message:

Added a SKIP keyword to ASSERT which skips the test instead of causing it to fail if its condition is false.

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/assert.pro

    r76 r90  
    1313;    msg : in, optional, type=string, default="Assertion failed" 
    1414;       message to throw if condition is not met 
    15 ;    arg : in, optional, type=string 
     15;    arg1 : in, optional, type=string 
    1616;       argument for any C format codes in msg 
     17;    arg2 : in, optional, type=string 
     18;       argument for any C format codes in msg 
     19;    arg3 : in, optional, type=string 
     20;       argument for any C format codes in msg 
     21; 
     22; :Keywords: 
     23;    skip : in, optional, type=boolean 
     24;       set to skip test instead of fail 
    1725;- 
    18 pro assert, condition, msg, arg 
     26pro assert, condition, msg, arg1, arg2, arg3, skip=skip 
    1927  compile_opt strictarr, logical_predicate, hidden 
    2028  on_error, 2 
    2129 
    22   case n_params() of 
    23     0:  
    24     1: if (~condition) then message, 'Assertion failed' 
    25     2: if (~condition) then message, msg 
    26     3: if (~condition) then message, string(arg, format='(%"' + msg + '")') 
    27   endcase 
     30  if (~condition) then begin 
     31    if (keyword_set(skip)) then (scope_varfetch('self', level=-1))->skip 
     32 
     33    case n_params() of 
     34      0:  
     35      1: message, 'Assertion failed' 
     36      2: message, msg 
     37      3: message, string(arg1, format='(%"' + msg + '")') 
     38      4: message, string(arg1, arg2, format='(%"' + msg + '")') 
     39      5: message, string(arg1, arg2, arg3, format='(%"' + msg + '")') 
     40    endcase 
     41  endif 
    2842end 
  • trunk/src/mguttestcase__define.pro

    r88 r90  
    2222  compile_opt strictarr 
    2323 
     24end 
     25 
     26 
     27;+ 
     28; Set this test to be skipped. 
     29;- 
     30pro mguttestcase::skip 
     31  compile_opt strictarr 
     32   
     33  self.skipped = 1 
    2434end 
    2535