MCPcopy Index your code
hub / github.com/prototypejs/prototype / functionThrows

Function functionThrows

test/unit/static/js/proclaim.js:474–492  ·  view source on GitHub ↗
(fn, expected)

Source from the content-addressed store, hash-verified

472
473 // Utility for testing whether a function throws an error
474 function functionThrows (fn, expected) {
475
476 // Try/catch
477 var thrown = false;
478 var thrownError;
479 try {
480 fn();
481 } catch (err) {
482 thrown = true;
483 thrownError = err;
484 }
485
486 // Check error
487 if (thrown && expected) {
488 thrown = errorMatches(thrownError, expected);
489 }
490
491 return thrown;
492 }
493
494 // Utility for checking whether an error matches a given constructor, regexp or string
495 function errorMatches (actual, expected) {

Callers 1

proclaim.jsFile · 0.70

Calls 1

errorMatchesFunction · 0.70

Tested by

no test coverage detected