test/intl/assert.js
/**
 * Runs code() and asserts that it throws the specified exception.
 */
Runs code() and asserts that it throws the specified exception.
Runs code () and asserts that it throws the specified exception .
function assertThrows(code, type_opt, cause_opt) {
  try {
    if (typeof code == 'function') {
      code();
    } else {
      eval(code);
    }
  } catch (e) {
    if (typeof type_opt == 'function') {
      assertInstanceof(e, type_opt);
    }
    if (arguments.length >= 3) {
      assertEquals(cause_opt, e.message, 'thrown exception type mismatch');
    }
    return;
  }
  var expected = arguments.length >= 3 ? cause_opt :
      typeof type_opt == 'function' ? type_opt : 'any exception';
  fail(expected, 'no exception', 'expected thrown exception');
}
function assertThrows ( code , type_opt , cause_opt ) { try { if ( typeof code == 'function' ) { code ( ) ; } else { eval ( code ) ; } } catch ( e ) { if ( typeof type_opt == 'function' ) { assertInstanceof ( e , type_opt ) ; } if ( arguments . length >= 3 ) { assertEquals ( cause_opt , e . message , 'thrown exception type mismatch' ) ; } return ; } var expected = arguments . length >= 3 ? cause_opt : typeof type_opt == 'function' ? type_opt : 'any exception' ; fail ( expected , 'no exception' , 'expected thrown exception' ) ; }
Runs code() and asserts that it throws the specified exception.
Runs code () and asserts that it throws the specified exception .
// Success.