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 = 1;      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 += ({ "Config" });    else -  +  res += ({ sprintf("%O", arg ) }); +  else    res+=({sprintf("%O",arg)}); -  } +     return res * ", ";   }      void report_1st(function cb, array args )   {    report_error(" Test %3d %-40s ", current_test,    sprintf("%O("+describe_arglist( args )+")",cb)[..39]);   }      string do_describe_error( mixed err )
Roxen.git/server/etc/test/tests/pike_test_common.pike:99:   void check_is_not_zero( mixed res, mixed err, function cb, array args, int st )   {    if( err )    report_test_failure( err, cb, args, st );    else    if( !res )    report_test_failure( "expected non-zero", cb, args, st);    else    report_test_ok( err, cb, args, st );   } +  +  + function check_is( mixed m ) + { +  return +  lambda( mixed res, mixed err, function cb, array args, int st ) +  { +  if( err ) +  report_test_failure( err, cb, args, st ); +  else +  if( res != m ) +  report_test_failure(sprintf("Got %O, expected %O", res,m), +  cb,args,st); +  else +  report_test_ok( err, cb, args, st ); +  }; + } +  + function check_equal( mixed m ) + { +  return +  lambda( mixed res, mixed err, function cb, array args, int st ) +  { +  if( err ) +  report_test_failure( err, cb, args, st ); +  else +  if( !equal( res, m )) +  report_test_failure(sprintf("Got %O, expected %O", res,m), +  cb,args,st); +  else +  report_test_ok( err, cb, args, st ); +  }; + } +  + function check_not_equal( mixed m ) + { +  return +  lambda( mixed res, mixed err, function cb, array args, int st ) +  { +  if( err ) +  report_test_failure( err, cb, args, st ); +  else +  if( equal( res, m )) +  report_test_failure(sprintf("Got %O, expected %O", res,m), +  cb,args,st); +  else +  report_test_ok( err, cb, args, st ); +  }; + }