michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: * Contributor: michael@0: * Jeff Walden michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 562446; michael@0: var summary = 'ES5: Array.prototype.toString'; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var o; michael@0: michael@0: o = { join: function() { assertEq(arguments.length, 0); return "ohai"; } }; michael@0: assertEq(Array.prototype.toString.call(o), "ohai"); michael@0: michael@0: o = {}; michael@0: assertEq(Array.prototype.toString.call(o), "[object Object]"); michael@0: michael@0: Array.prototype.join = function() { return "kthxbai"; }; michael@0: assertEq(Array.prototype.toString.call([]), "kthxbai"); michael@0: michael@0: o = { join: 17 }; michael@0: assertEq(Array.prototype.toString.call(o), "[object Object]"); michael@0: michael@0: o = { get join() { throw 42; } }; michael@0: try michael@0: { michael@0: var str = Array.prototype.toString.call(o); michael@0: assertEq(true, false, michael@0: "expected an exception calling [].toString on an object with a " + michael@0: "join getter that throws, got " + str + " instead"); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e, 42, michael@0: "expected thrown e === 42 when calling [].toString on an object " + michael@0: "with a join getter that throws, got " + e); michael@0: } michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("All tests passed!");