Roxen.git / server / etc / test / tests / pike_test_common.pike

version» Context lines:

Roxen.git/server/etc/test/tests/pike_test_common.pike:1:   int current_test, tests_failed;   int verbose;      void create( int vb ) { verbose = vb; }       - string describe_arglist( array args ) - { -  array res = ({}); -  foreach( args, mixed arg ) -  if( mappingp(arg) || arrayp(arg) ) -  res+=({sprintf("%t<%d>",arg,sizeof(arg))}); -  else if( objectp( arg ) ) -  if( arg->is_module ) -  res += ({ sprintf("%s",arg->my_configuration()->otomod[arg])}); -  else if( arg->is_configuration ) -  res += ({ sprintf("%s", arg->name ) }); -  else -  res += ({ sprintf("%O", arg ) }); -  else -  res+=({sprintf("%O",arg)}); -  return replace(res * ", ","%","%%"); - } -  +    string describe_test (function|string cb, array args)   { -  if (functionp (cb)) -  return sprintf ("%O(%s)", cb, describe_arglist (args)); +  if (!stringp (cb)) { +  object describer = master()->Describer(); +  return describer->describe (cb) + +  "(" + describer->describe_comma_list (args, 512) + ")"; +  }    if (sizeof (args))    catch {return sprintf (cb, @args);};    return cb;   }      string pad_to_column (string str, int col, string cont_prefix)   {    array(string) split = str / "\n";    if (sizeof (split) > 1 && split[-1] == "") split = split[..<1];    if (sizeof (split[-1]) > col) split += ({""});
Roxen.git/server/etc/test/tests/pike_test_common.pike:135:    else    report_test_ok( err, cb, args,st );    return result;   }      mixed test_really_generic( function check_return, function(void:mixed) test_fn,    string|array test_text, array test_text_args )   {    current_test++;    mixed result; -  report_1st( test_text, test_text_args, check_return ); +     int st = gethrtime();    mixed err = catch {    result = test_fn();    }; -  +  +  // Write out the test after running it, since the macros change +  // test_text_args in the test. +  report_1st( test_text, test_text_args, check_return ); +     if( check_return )    check_return( result, err, test_text, test_text_args,st );    else if( err )    report_test_failure( err, test_text, test_text_args,st );    else    report_test_ok( err, test_text, test_text_args,st );    return result;   }      
Roxen.git/server/etc/test/tests/pike_test_common.pike:184:   {    if( err )    report_test_failure( err, cb, args, st );    else    if( !objectp(res) || !res->is_configuration )    report_test_failure( sprintf("Got %O, expected configuration", res),cb,args, st);    else    report_test_ok( err, cb, args, st );   }    + void silent_check_true( mixed res, mixed err, +  function|string|array cb, array args, int st ) + { +  if (err || !res) +  report_test_failure( err, cb, args, st ); +  else +  report_test_ok( 0, cb, args, st ); + }      void check_true( mixed res, mixed err,    function|string|array cb, array args, int st )   {    if( err )    report_test_failure( err, cb, args, st );    else    if( !res )    report_test_failure( sprintf ("expected non-zero, got %O", res),    cb, args, st);
Roxen.git/server/etc/test/tests/pike_test_common.pike:264:    report_test_failure( err, cb, args, st );    else    if( equal( res, m ))    report_test_failure(sprintf("Got %O, expected different value", res),    cb,args,st);    else    report_test_ok( err, cb, args, st );    };   }    -  +    mixed cpp_test_true (string file, int line, function(void:mixed) test_fn,    string test_text, array test_text_args)   { -  return test_really_generic (check_true, test_fn, +  return test_really_generic (silent_check_true, test_fn,    ({file, line, test_text}), test_text_args);   }      mixed test( function|array f, mixed ... args )   {    return test_generic( 0, f, @args );   }      mixed test_true( function|array f, mixed ... args )   {