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

Function functionThrows

test/unit/static/js/assertions.js:103–121  ·  view source on GitHub ↗
(fn, expected)

Source from the content-addressed store, hash-verified

101
102 // Utility for testing whether a function throws an error
103 function functionThrows (fn, expected) {
104
105 // Try/catch
106 var thrown = false;
107 var thrownError;
108 try {
109 fn();
110 } catch (err) {
111 thrown = true;
112 thrownError = err;
113 }
114
115 // Check error
116 if (thrown && expected) {
117 thrown = errorMatches(thrownError, expected);
118 }
119
120 return thrown;
121 }
122
123 // Utility for checking whether an error matches a given constructor, regexp or string
124 function errorMatches (actual, expected) {

Callers 1

assertions.jsFile · 0.70

Calls 1

errorMatchesFunction · 0.70

Tested by

no test coverage detected