Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / negate-overflow.html
blob4f412c1d70ffd8f1ee204fc55997d1320907e06a
1 <p>Test for overflow when negating the largest negative signed int.</p>
2 <p>If the test passes, you'll see a series of PASS messages below.</p>
4 <pre id="console"></pre>
6 <script>
7 function $(id)
9 return document.getElementById(id);
12 function log(s)
14 $("console").appendChild(document.createTextNode(s + "\n"));
17 function shouldBe(aDescription, a, b)
19 if (a === b) {
20 log("PASS: " + aDescription + " should be " + b + " and is.");
21 } else {
22 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
26 (function () {
27 if (window.testRunner)
28 testRunner.dumpAsText();
30 // Can be constant-folded by the parser.
31 var x = -(-2147483648);
32 shouldBe("x", x, 2147483648);
34 // Can't be constant-folded without dataflow analysis.
35 var y = -2147483648;
36 y = -y;
37 shouldBe("y", y, 2147483648);
38 })();
39 </script>