blob: 4f412c1d70ffd8f1ee204fc55997d1320907e06a [file] [log] [blame]
<p>Test for overflow when negating the largest negative signed int.</p>
<p>If the test passes, you'll see a series of PASS messages below.</p>
<pre id="console"></pre>
<script>
function $(id)
{
return document.getElementById(id);
}
function log(s)
{
$("console").appendChild(document.createTextNode(s + "\n"));
}
function shouldBe(aDescription, a, b)
{
if (a === b) {
log("PASS: " + aDescription + " should be " + b + " and is.");
} else {
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
}
}
(function () {
if (window.testRunner)
testRunner.dumpAsText();
// Can be constant-folded by the parser.
var x = -(-2147483648);
shouldBe("x", x, 2147483648);
// Can't be constant-folded without dataflow analysis.
var y = -2147483648;
y = -y;
shouldBe("y", y, 2147483648);
})();
</script>