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

Unified Diff: test/mjsunit/harmony/math-trunc.js

Issue 28793002: Harmony: implement Math.trunc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: inline number conversion Created 7 years, 2 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 | « src/math.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/math-trunc.js
diff --git a/test/mjsunit/harmony/math-sign.js b/test/mjsunit/harmony/math-trunc.js
similarity index 59%
copy from test/mjsunit/harmony/math-sign.js
copy to test/mjsunit/harmony/math-trunc.js
index 8a89d62828bdbd43a972498f0b32d1a27939171e..ed91ed1380f54ff46cf7b125dae87863b54baee7 100644
--- a/test/mjsunit/harmony/math-sign.js
+++ b/test/mjsunit/harmony/math-trunc.js
@@ -27,22 +27,25 @@
// Flags: --harmony-maths
-assertEquals("Infinity", String(1/Math.sign(0)));
-assertEquals("-Infinity", String(1/Math.sign(-0)));
-assertEquals(1, Math.sign(100));
-assertEquals(-1, Math.sign(-199));
-assertEquals(1, Math.sign(100.1));
-assertTrue(isNaN(Math.sign("abc")));
-assertTrue(isNaN(Math.sign({})));
-assertEquals(0, Math.sign([]));
-assertEquals(1, Math.sign([1]));
-assertEquals(-1, Math.sign([-100.1]));
-assertTrue(isNaN(Math.sign([1, 1])));
-assertEquals(1, Math.sign({ toString: function() { return "100"; } }));
-assertEquals(1, Math.sign({ toString: function() { return 100; } }));
-assertEquals(-1, Math.sign({ valueOf: function() { return -1.1; } }));
-assertEquals(-1, Math.sign({ valueOf: function() { return "-1.1"; } }));
-assertEquals(-1, Math.sign(-Infinity));
-assertEquals(1, Math.sign(Infinity));
-assertEquals(-1, Math.sign("-Infinity"));
-assertEquals(1, Math.sign("Infinity"));
+assertEquals("Infinity", String(1/Math.trunc(0)));
+assertEquals("-Infinity", String(1/Math.trunc(-0)));
+assertEquals("Infinity", String(1/Math.trunc(Math.PI/4)));
+assertEquals("-Infinity", String(1/Math.trunc(-Math.sqrt(2)/2)));
+assertEquals(100, Math.trunc(100));
+assertEquals(-199, Math.trunc(-199));
+assertEquals(100, Math.trunc(100.1));
+assertTrue(isNaN(Math.trunc("abc")));
+assertTrue(isNaN(Math.trunc({})));
+assertEquals(0, Math.trunc([]));
+assertEquals(1, Math.trunc([1]));
+assertEquals(-100, Math.trunc([-100.1]));
+assertTrue(isNaN(Math.trunc([1, 1])));
+assertEquals(-100, Math.trunc({ toString: function() { return "-100.3"; } }));
+assertEquals(10, Math.trunc({ toString: function() { return 10.1; } }));
+assertEquals(-1, Math.trunc({ valueOf: function() { return -1.1; } }));
+assertEquals("-Infinity",
+ String(1/Math.trunc({ valueOf: function() { return "-0.1"; } })));
+assertEquals("-Infinity", String(Math.trunc(-Infinity)));
+assertEquals("Infinity", String(Math.trunc(Infinity)));
+assertEquals("-Infinity", String(Math.trunc("-Infinity")));
+assertEquals("Infinity", String(Math.trunc("Infinity")));
« no previous file with comments | « src/math.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698