B2G/gecko/dom/mobilemessage/tests/header_helpers.js
/**
 * Test whether specified function throws exception with expected
 * result.
 *
 * @param func
 *        Function to be tested.
 * @param exception
 *        Expected class name of thrown exception. Use null for no throws.
 * @param stack
 *        Optional stack object to be printed. null for Components#stack#caller.
 */
Test whether specified function throws exception with expected
result.

@param func
Function to be tested.
@param exception
Expected class name of thrown exception. Use null for no throws.
@param stack
Optional stack object to be printed. null for Components#stack#caller.
Test whether specified function throws exception with expected result . @param func Function to be tested . @param exception Expected class name of thrown exception . Use null for no throws . @param stack Optional stack object to be printed . null for Components#stack#caller .
function do_check_throws(func, result, stack)
{
  if (!stack)
    stack = Components.stack.caller;
  try {
    func();
  } catch (ex) {
    if (ex.name == result) {
      return;
    }
    do_throw("expected result " + result + ", caught " + ex, stack);
  }
  if (result) {
    do_throw("expected result " + result + ", none thrown", stack);
  }
}
function do_check_throws ( func , result , stack ) { if ( ! stack ) stack = Components . stack . caller ; try { func ( ) ; } catch ( ex ) { if ( ex . name == result ) { return ; } do_throw ( "expected result " + result + ", caught " + ex , stack ) ; } if ( result ) { do_throw ( "expected result " + result + ", none thrown" , stack ) ; } }
Test whether specified function throws exception with expected
 result.
Test whether specified function throws exception with expected result .