Reviewers: arv,

Message:
PTAL.

Description:
Add test case for custom error's toString.

[email protected]
BUG=
TEST=error-tostring.js


Please review this at http://codereview.chromium.org/10388208/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M test/mjsunit/error-tostring.js


Index: test/mjsunit/error-tostring.js
diff --git a/test/mjsunit/error-tostring.js b/test/mjsunit/error-tostring.js
index a28564144f8bcd4267a27dc1e4a9f797d68ab74f..59e7149c21ad9f8a8fe51620f74f209a886f6e07 100644
--- a/test/mjsunit/error-tostring.js
+++ b/test/mjsunit/error-tostring.js
@@ -83,3 +83,22 @@ assertEquals(["Error: e2",[1,3,4]], testErrorToString(undefined, "e2"));
 assertEquals(["null: e2",[1,2,3,4]], testErrorToString(null, "e2"));
 assertEquals(["e2",[1,2,3,4]], testErrorToString("", "e2"));
 assertEquals(["e1: e2",[1,2,3,4]], testErrorToString("e1", "e2"));
+
+
+// Test that a custom error object does not use Error.prototype.toString.
+
+function MyError(name, message) {
+  this.name = name;
+  this.message = message;
+}
+
+MyError.prototype = Object.create(Error.prototype);
+MyError.prototype.toString = function() {
+  return 'MyError toString';
+};
+
+try {
+  throw new MyError('name', 'message');
+} catch (e) {
+  assertEquals('MyError toString', e.toString());
+}


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to