Index: test/mjsunit/math-floor-part4.js |
diff --git a/test/mjsunit/regress/regress-1132.js b/test/mjsunit/math-floor-part4.js |
similarity index 57% |
copy from test/mjsunit/regress/regress-1132.js |
copy to test/mjsunit/math-floor-part4.js |
index 3314db85727272f274f556db3ac415b352201e7e..c63362308342270b41965a91341098b011c1354f 100644 |
--- a/test/mjsunit/regress/regress-1132.js |
+++ b/test/mjsunit/math-floor-part4.js |
@@ -25,26 +25,52 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Test the case when exception is thrown from the parser when lazy |
-// compiling a function. |
+// Flags: --max-new-space-size=256 --allow-natives-syntax |
-// Flags: --stack_size=32 |
-// NOTE: stack size constant above has been empirically chosen. |
-// If the test starts to fail in Genesis, consider increasing this constant. |
+var test_id = 0; |
+ |
+function testFloor(expect, input) { |
+ var test = new Function('n', |
+ '"' + (test_id++) + '";return Math.floor(n)'); |
+ assertEquals(expect, test(input)); |
+ assertEquals(expect, test(input)); |
+ assertEquals(expect, test(input)); |
+ %OptimizeFunctionOnNextCall(test); |
+ assertEquals(expect, test(input)); |
+} |
+ |
+function zero() { |
+ var x = 0.5; |
+ return (function() { return x - 0.5; })(); |
+} |
function test() { |
- try { |
- test(1, test(1)); |
- } catch(e) { |
- assertFalse(delete e, "deleting catch variable"); |
- assertEquals(42, e); |
- } |
+ testFloor(0, 0); |
+ testFloor(0, zero()); |
+ testFloor(-0, -0); |
+ testFloor(Infinity, Infinity); |
+ testFloor(-Infinity, -Infinity); |
+ testFloor(NaN, NaN); |
} |
-var exception = false; |
-try { |
+ |
+// Test in a loop to cover the custom IC and GC-related issues. |
+for (var i = 0; i < 100; i++) { |
test(); |
-} catch (e) { |
- exception = true; |
} |
-assertTrue(exception); |
+ |
+ |
+// Regression test for a bug where a negative zero coming from Math.floor |
+// was not properly handled by other operations. |
+function floorsum(i, n) { |
+ var ret = Math.floor(n); |
+ while (--i > 0) { |
+ ret += Math.floor(n); |
+ } |
+ return ret; |
+} |
+assertEquals(-0, floorsum(1, -0)); |
+%OptimizeFunctionOnNextCall(floorsum); |
+// The optimized function will deopt. Run it with enough iterations to try |
+// to optimize via OSR (triggering the bug). |
+assertEquals(-0, floorsum(100000, -0)); |
Yang
2012/09/24 09:19:26
It seems that this part has been added in r8877 as
Jakob Kummerow
2012/09/24 09:31:21
As discussed offline, let's leave this where it is
|