Index: test/mjsunit/regress/regress-2263.js |
diff --git a/test/mjsunit/regress/regress-2263.js b/test/mjsunit/regress/regress-2263.js |
index 9a9db58773b18af75e686f8d11b607de867fde53..9e4b079bdc61af52a3c9e630e19a20ff6bde0ceb 100644 |
--- a/test/mjsunit/regress/regress-2263.js |
+++ b/test/mjsunit/regress/regress-2263.js |
@@ -25,6 +25,30 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+assertThrows = function assertThrows(code, type_opt, cause_opt) { |
+ var threwException = true; |
+ try { |
+ if (typeof code === 'function') { |
+ code(); |
+ } else { |
+ eval(code); |
+ } |
+ threwException = false; |
+ } catch (e) { |
+ if (typeof type_opt === 'function') { |
+ assertInstanceof(e, type_opt); |
+ } else if (type_opt !== void 0) { |
+ failWithMessage("invalid use of assertThrows, maybe you want assertThrowsEquals"); |
+ } |
+ if (arguments.length >= 3) { |
+ assertEquals(e.type, cause_opt); |
+ } |
+ // Success. |
+ return; |
+ } |
+ failWithMessage("Did not throw exception"); |
+}; |
+ |
var obj = { length: { valueOf: function(){ throw { type: "length" }}}}; |
var sep = { toString: function(){ throw { type: "toString" }}}; |
assertThrows("Array.prototype.join.call(obj, sep)", undefined, "length"); |