Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Unified Diff: test/mjsunit/math-floor-part4.js

Issue 10967064: Split test/mjsunit/math-floor into smaller chunks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/math-floor-part3.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « test/mjsunit/math-floor-part3.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698