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

Side by Side Diff: test/mjsunit/number-tostring.js

Issue 6869007: Cleanup of mjsunit.js code and make assertEquals more strict. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/number-string-index-call.js ('k') | test/mjsunit/object-seal.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 assertEquals("1e-8", (0.00000001).toString()); 48 assertEquals("1e-8", (0.00000001).toString());
49 assertEquals("1.2e-8", (0.000000012).toString()); 49 assertEquals("1.2e-8", (0.000000012).toString());
50 assertEquals("1.23e-8", (0.0000000123).toString()); 50 assertEquals("1.23e-8", (0.0000000123).toString());
51 51
52 assertEquals("0", (-0).toString()); 52 assertEquals("0", (-0).toString());
53 assertEquals("-9", (-9).toString()); 53 assertEquals("-9", (-9).toString());
54 assertEquals("-90", (-90).toString()); 54 assertEquals("-90", (-90).toString());
55 assertEquals("-90.12", (-90.12).toString()); 55 assertEquals("-90.12", (-90.12).toString());
56 assertEquals("-0.1", (-0.1).toString()); 56 assertEquals("-0.1", (-0.1).toString());
57 assertEquals("-0.01", (-0.01).toString()); 57 assertEquals("-0.01", (-0.01).toString());
58 assertEquals("-0.0123", (-0.0123).toString()) 58 assertEquals("-0.0123", (-0.0123).toString());
59 assertEquals("-111111111111111110000", (-111111111111111111111).toString()); 59 assertEquals("-111111111111111110000", (-111111111111111111111).toString());
60 assertEquals("-1.1111111111111111e+21", (-1111111111111111111111).toString()); 60 assertEquals("-1.1111111111111111e+21", (-1111111111111111111111).toString());
61 assertEquals("-1.1111111111111111e+22", (-11111111111111111111111).toString()); 61 assertEquals("-1.1111111111111111e+22", (-11111111111111111111111).toString());
62 assertEquals("-0.00001", (-0.00001).toString()); 62 assertEquals("-0.00001", (-0.00001).toString());
63 assertEquals("-0.000001", (-0.000001).toString()); 63 assertEquals("-0.000001", (-0.000001).toString());
64 assertEquals("-1e-7", (-0.0000001).toString()); 64 assertEquals("-1e-7", (-0.0000001).toString());
65 assertEquals("-1.2e-7", (-0.00000012).toString()); 65 assertEquals("-1.2e-7", (-0.00000012).toString());
66 assertEquals("-1.23e-7", (-0.000000123).toString()); 66 assertEquals("-1.23e-7", (-0.000000123).toString());
67 assertEquals("-1e-8", (-0.00000001).toString()); 67 assertEquals("-1e-8", (-0.00000001).toString());
68 assertEquals("-1.2e-8", (-0.000000012).toString()); 68 assertEquals("-1.2e-8", (-0.000000012).toString());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 assertEquals("10000000000000128.00", (10000000000000128).toFixed(2)); 212 assertEquals("10000000000000128.00", (10000000000000128).toFixed(2));
213 assertEquals("10000000000000128.00000000000000000000", (10000000000000128).toFix ed(20)); 213 assertEquals("10000000000000128.00000000000000000000", (10000000000000128).toFix ed(20));
214 assertEquals("0", (0).toFixed()); 214 assertEquals("0", (0).toFixed());
215 assertEquals("-42.000", ((-42).toFixed(3))); 215 assertEquals("-42.000", ((-42).toFixed(3)));
216 assertEquals("-1000000000000000128", (-1000000000000000128).toFixed()); 216 assertEquals("-1000000000000000128", (-1000000000000000128).toFixed());
217 assertEquals("-0.00000000000000000010", (-0.0000000000000000001).toFixed(20)); 217 assertEquals("-0.00000000000000000010", (-0.0000000000000000001).toFixed(20));
218 assertEquals("0.12312312312312299889", (0.123123123123123).toFixed(20)); 218 assertEquals("0.12312312312312299889", (0.123123123123123).toFixed(20));
219 // Test that we round up even when the last digit generated is even. 219 // Test that we round up even when the last digit generated is even.
220 // dtoa does not do this in its original form. 220 // dtoa does not do this in its original form.
221 assertEquals("1", 0.5.toFixed(0), "0.5.toFixed(0)"); 221 assertEquals("1", 0.5.toFixed(0), "0.5.toFixed(0)");
222 assertEquals("-1", -0.5.toFixed(0), "-0.5.toFixed(0)"); 222 assertEquals("-1", (-0.5).toFixed(0), "(-0.5).toFixed(0)");
223 assertEquals("1.3", 1.25.toFixed(1), "1.25.toFixed(1)"); 223 assertEquals("1.3", 1.25.toFixed(1), "1.25.toFixed(1)");
224 // This is bizare, but Spidermonkey and KJS behave the same. 224 // This is bizare, but Spidermonkey and KJS behave the same.
225 assertEquals("234.2040", (234.20405).toFixed(4), "234.2040.toFixed(4)"); 225 assertEquals("234.2040", (234.20405).toFixed(4), "234.2040.toFixed(4)");
226 assertEquals("234.2041", (234.2040506).toFixed(4)); 226 assertEquals("234.2041", (234.2040506).toFixed(4));
227 227
228 // ---------------------------------------------------------------------- 228 // ----------------------------------------------------------------------
229 // toExponential 229 // toExponential
230 assertEquals("1e+0", (1).toExponential()); 230 assertEquals("1e+0", (1).toExponential());
231 assertEquals("1.1e+1", (11).toExponential()); 231 assertEquals("1.1e+1", (11).toExponential());
232 assertEquals("1.12e+2", (112).toExponential()); 232 assertEquals("1.12e+2", (112).toExponential());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 assertEquals("-1.2e+4", Number(-12345).toPrecision(2)); 331 assertEquals("-1.2e+4", Number(-12345).toPrecision(2));
332 assertEquals("-1.235e+4", Number(-12345.67).toPrecision(4)); 332 assertEquals("-1.235e+4", Number(-12345.67).toPrecision(4));
333 assertEquals("-1.234e+4", Number(-12344.67).toPrecision(4)); 333 assertEquals("-1.234e+4", Number(-12344.67).toPrecision(4));
334 // Test that we round up even when the last digit generated is even. 334 // Test that we round up even when the last digit generated is even.
335 // dtoa does not do this in its original form. 335 // dtoa does not do this in its original form.
336 assertEquals("1.3", 1.25.toPrecision(2), "1.25.toPrecision(2)"); 336 assertEquals("1.3", 1.25.toPrecision(2), "1.25.toPrecision(2)");
337 assertEquals("1.4", 1.35.toPrecision(2), "1.35.toPrecision(2)"); 337 assertEquals("1.4", 1.35.toPrecision(2), "1.35.toPrecision(2)");
338 338
339 339
340 340
OLDNEW
« no previous file with comments | « test/mjsunit/number-string-index-call.js ('k') | test/mjsunit/object-seal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698