1 <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>
3 <pre id=
"console"></pre>
8 document
.getElementById("console").appendChild(document
.createTextNode(s
+ "\n"));
11 function shouldBe(a
, aDescription
, b
)
14 log("PASS: " + aDescription
+ " should be " + b
+ " and is.");
16 log("FAIL: " + aDescription
+ " should be " + b
+ " but instead is " + a
+ ".");
20 testRunner
.dumpAsText();
23 valueOf
: function valueOf() { return 0; },
24 toString
: function toString() { return 1; }
27 shouldBe('1' + valueOfIsZero
, "'1' + valueOfIsZero", "10");