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

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: 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
Index: test/mjsunit/harmony/math-trunc.js
diff --git a/test/intl/break-iterator/zh-break.js b/test/mjsunit/harmony/math-trunc.js
similarity index 58%
copy from test/intl/break-iterator/zh-break.js
copy to test/mjsunit/harmony/math-trunc.js
index c8434b10c2f145267e2d07a604f79eb05f187c9b..ed91ed1380f54ff46cf7b125dae87863b54baee7 100644
--- a/test/intl/break-iterator/zh-break.js
+++ b/test/mjsunit/harmony/math-trunc.js
@@ -25,39 +25,27 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Segment plain Chinese sentence and check results.
-
-var iterator = new Intl.v8BreakIterator(['zh']);
-
-var textToSegment = '\u56FD\u52A1\u9662\u5173\u4E8E\u300A\u571F\u5730' +
- '\u623F\u5C4B\u7BA1\u7406\u6761\u4F8B\u300B';
-iterator.adoptText(textToSegment);
-
-var slices = [];
-var types = [];
-var pos = iterator.first();
-while (pos !== -1) {
- var nextPos = iterator.next();
- if (nextPos === -1) break;
-
- slices.push(textToSegment.slice(pos, nextPos));
- types.push(iterator.breakType());
-
- pos = nextPos;
-}
-
-assertEquals('\u56FD\u52A1\u9662', slices[0]);
-assertEquals('\u5173\u4E8E', slices[1]);
-assertEquals('\u300A', slices[2]);
-assertEquals('\u571F\u5730', slices[3]);
-assertEquals('\u623F\u5C4B', slices[4]);
-assertEquals('\u7BA1\u7406', slices[5]);
-assertEquals('\u6761\u4F8B', slices[6]);
-assertEquals('\u300B', slices[7]);
-
-assertEquals('ideo', types[0]);
-assertEquals('ideo', types[1]);
-assertEquals('none', types[2]);
-assertEquals('ideo', types[3]);
-assertEquals('ideo', types[4]);
-assertEquals('none', types[types.length - 1]);
+// Flags: --harmony-maths
+
+assertEquals("Infinity", String(1/Math.trunc(0)));
+assertEquals("-Infinity", String(1/Math.trunc(-0)));
Dmitry Lomov (no reviews) 2013/10/21 07:01:28 Get -0 in some "cleverer" way here, otherwise it m
+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")));
« src/harmony-math.js ('K') | « test/mjsunit/harmony/math-sign.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698