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

Unified Diff: test/mjsunit/regress/regress-2263.js

Issue 2525313003: [mjsunit] Change assertThrows such that it can check the exception message. (Closed)
Patch Set: assertTraps actually exists in wasm-constants.js Created 4 years, 1 month 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/mjsunit.js ('k') | test/mjsunit/wasm/divrem-trap.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « test/mjsunit/mjsunit.js ('k') | test/mjsunit/wasm/divrem-trap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698