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

Side by Side Diff: test/mjsunit/parse-int-float.js

Issue 1529004: StringToInt rewritten. This version doesn't allocate memory for long decimals... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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
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 24 matching lines...) Expand all
35 assertEquals(-63, parseInt(' -077')); 35 assertEquals(-63, parseInt(' -077'));
36 36
37 assertEquals(3, parseInt('11', 2)); 37 assertEquals(3, parseInt('11', 2));
38 assertEquals(4, parseInt('11', 3)); 38 assertEquals(4, parseInt('11', 3));
39 assertEquals(4, parseInt('11', 3.8)); 39 assertEquals(4, parseInt('11', 3.8));
40 40
41 assertEquals(0x12, parseInt('0x12')); 41 assertEquals(0x12, parseInt('0x12'));
42 assertEquals(0x12, parseInt('0x12', 16)); 42 assertEquals(0x12, parseInt('0x12', 16));
43 assertEquals(0x12, parseInt('0x12', 16.1)); 43 assertEquals(0x12, parseInt('0x12', 16.1));
44 assertEquals(0x12, parseInt('0x12', NaN)); 44 assertEquals(0x12, parseInt('0x12', NaN));
45 45 assertTrue(isNaN(parseInt('0x ')));
46 assertTrue(isNaN(parseInt('0x')));
47 assertTrue(isNaN(parseInt('0x ', 16)));
48 assertTrue(isNaN(parseInt('0x', 16)));
46 assertEquals(12, parseInt('12aaa')); 49 assertEquals(12, parseInt('12aaa'));
47 50
48 assertEquals(0.1, parseFloat('0.1')); 51 assertEquals(0.1, parseFloat('0.1'));
49 assertEquals(0.1, parseFloat('0.1aaa')); 52 assertEquals(0.1, parseFloat('0.1aaa'));
50 assertEquals(0, parseFloat('0aaa')); 53 assertEquals(0, parseFloat('0aaa'));
51 assertEquals(0, parseFloat('0x12')); 54 assertEquals(0, parseFloat('0x12'));
52 assertEquals(77, parseFloat('077')); 55 assertEquals(77, parseFloat('077'));
53 56
57 assertEquals(Infinity, parseInt('1000000000000000000000000000000000000000000000'
58 + '000000000000000000000000000000000000000000000000000000000000000000000000'
59 + '000000000000000000000000000000000000000000000000000000000000000000000000'
60 + '000000000000000000000000000000000000000000000000000000000000000000000000'
61 + '000000000000000000000000000000000000000000000000000000000000000000000000'
62 + '0000000000000'));
63
64 assertEquals(Infinity, parseInt('0x10000000000000000000000000000000000000000000'
65 + '000000000000000000000000000000000000000000000000000000000000000000000000'
66 + '000000000000000000000000000000000000000000000000000000000000000000000000'
67 + '000000000000000000000000000000000000000000000000000000000000000000000000'
68 + '000000000000000000000000000000000000000000000000000000000000000000000000'
69 + '0000000000000'));
70
54 71
55 var i; 72 var i;
56 var y = 10; 73 var y = 10;
57 74
58 for (i = 1; i < 21; i++) { 75 for (i = 1; i < 21; i++) {
59 var x = eval("1.2e" + i); 76 var x = eval("1.2e" + i);
60 assertEquals(Math.floor(x), parseInt(x)); 77 assertEquals(Math.floor(x), parseInt(x));
61 x = eval("1e" + i); 78 x = eval("1e" + i);
62 assertEquals(x, y); 79 assertEquals(x, y);
63 y *= 10; 80 y *= 10;
(...skipping 13 matching lines...) Expand all
77 94
78 assertTrue(isNaN(parseInt(0/0))); 95 assertTrue(isNaN(parseInt(0/0)));
79 assertTrue(isNaN(parseInt(1/0)), "parseInt Infinity"); 96 assertTrue(isNaN(parseInt(1/0)), "parseInt Infinity");
80 assertTrue(isNaN(parseInt(-1/0)), "parseInt -Infinity"); 97 assertTrue(isNaN(parseInt(-1/0)), "parseInt -Infinity");
81 98
82 assertTrue(isNaN(parseFloat(0/0))); 99 assertTrue(isNaN(parseFloat(0/0)));
83 assertEquals(Infinity, parseFloat(1/0), "parseFloat Infinity"); 100 assertEquals(Infinity, parseFloat(1/0), "parseFloat Infinity");
84 assertEquals(-Infinity, parseFloat(-1/0), "parseFloat -Infinity"); 101 assertEquals(-Infinity, parseFloat(-1/0), "parseFloat -Infinity");
85 102
86 103
OLDNEW
« src/conversions.cc ('K') | « src/runtime.cc ('k') | test/mjsunit/str-to-num.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698