blob: 21a1de43d44031e8d30dbe569295fb3dfc1f1041 [file] [log] [blame]
<p>This page tests that string addition prefers valueOf() over toString() for conversion. If the test passes, you'll see a PASS message below.</p>
<pre id="console"></pre>
<script>
function log(s)
{
document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}
function shouldBe(a, aDescription, b)
{
if (a === b)
log("PASS: " + aDescription + " should be " + b + " and is.");
else
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
}
if (this.testRunner)
testRunner.dumpAsText();
var valueOfIsZero = {
valueOf: function valueOf() { return 0; },
toString: function toString() { return 1; }
};
shouldBe('1' + valueOfIsZero, "'1' + valueOfIsZero", "10");
</script>