2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
5 * Jeff Walden <jwalden+code@mit.edu>
8 //-----------------------------------------------------------------------------
9 var BUGNUMBER = 562446;
10 var summary = 'ES5: Array.prototype.toString';
12 print(BUGNUMBER + ": " + summary);
20 o = { join: function() { assertEq(arguments.length, 0); return "ohai"; } };
21 assertEq(Array.prototype.toString.call(o), "ohai");
24 assertEq(Array.prototype.toString.call(o), "[object Object]");
26 Array.prototype.join = function() { return "kthxbai"; };
27 assertEq(Array.prototype.toString.call([]), "kthxbai");
30 assertEq(Array.prototype.toString.call(o), "[object Object]");
32 o = { get join() { throw 42; } };
35 var str = Array.prototype.toString.call(o);
37 "expected an exception calling [].toString on an object with a " +
38 "join getter that throws, got " + str + " instead");
43 "expected thrown e === 42 when calling [].toString on an object " +
44 "with a join getter that throws, got " + e);
47 /******************************************************************************/
49 if (typeof reportCompare === "function")
50 reportCompare(true, true);
52 print("All tests passed!");