Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: test/mjsunit/mjsunit.js

Issue 1544793002: [tests] Fix bogus uses of assertThrows. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/harmony/reflect.js ('k') | test/mjsunit/regress/regress-70066.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/mjsunit.js
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js
index 27f4d3942ad035fe9f743702381c7e6cff783737..9b07953c8aa22a24cd1386e1f212027dab0c7e2f 100644
--- a/test/mjsunit/mjsunit.js
+++ b/test/mjsunit/mjsunit.js
@@ -93,6 +93,10 @@ var assertNotNull;
// to the type property on the thrown exception.
var assertThrows;
+// Assert that the passed function throws an exception.
+// The exception is checked against the second argument using assertEquals.
+var assertThrowsEquals;
+
// Assert that the passed function or eval code does not throw an exception.
var assertDoesNotThrow;
@@ -353,6 +357,8 @@ var assertUnoptimized;
} catch (e) {
if (typeof type_opt === 'function') {
assertInstanceof(e, type_opt);
+ } else if (type_opt !== void 0) {
+ fail("invalid use of assertThrows, maybe you want assertThrowsEquals");
}
if (arguments.length >= 3) {
assertEquals(e.type, cause_opt);
@@ -364,6 +370,17 @@ var assertUnoptimized;
};
+ assertThrowsEquals = function assertThrowsEquals(fun, val) {
+ try {
+ fun();
+ } catch(e) {
+ assertEquals(val, e);
+ return;
+ }
+ throw new MjsUnitAssertionError("Did not throw exception");
+ };
+
+
assertInstanceof = function assertInstanceof(obj, type) {
if (!(obj instanceof type)) {
var actualTypeName = null;
« no previous file with comments | « test/mjsunit/harmony/reflect.js ('k') | test/mjsunit/regress/regress-70066.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698