Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / add-to-primitive.html
blob21a1de43d44031e8d30dbe569295fb3dfc1f1041
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>
5 <script>
6 function log(s)
8 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
11 function shouldBe(a, aDescription, b)
13 if (a === b)
14 log("PASS: " + aDescription + " should be " + b + " and is.");
15 else
16 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
19 if (this.testRunner)
20 testRunner.dumpAsText();
22 var valueOfIsZero = {
23 valueOf: function valueOf() { return 0; },
24 toString: function toString() { return 1; }
27 shouldBe('1' + valueOfIsZero, "'1' + valueOfIsZero", "10");
29 </script>