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

Side by Side Diff: test/mjsunit/str-to-num.js

Issue 1374005: Percise rounding parsing octal and hexadecimal strings.... (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
« no previous file with comments | « test/mjsunit/number-tostring.js ('k') | no next file » | 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 26 matching lines...) Expand all
37 num >>= 1; 37 num >>= 1;
38 } 38 }
39 39
40 return result; 40 return result;
41 } 41 }
42 42
43 assertEquals('0000000000', repeat('0', 10)); 43 assertEquals('0000000000', repeat('0', 10));
44 44
45 // assertEquals(, toNumber()); 45 // assertEquals(, toNumber());
46 46
47
48 assertEquals(123, toNumber(" 123")); 47 assertEquals(123, toNumber(" 123"));
49 assertEquals(123, toNumber("\n123")); 48 assertEquals(123, toNumber("\n123"));
50 assertEquals(123, toNumber("\r123")); 49 assertEquals(123, toNumber("\r123"));
51 assertEquals(123, toNumber("\t123")); 50 assertEquals(123, toNumber("\t123"));
52 assertEquals(123, toNumber("\f123")); 51 assertEquals(123, toNumber("\f123"));
53 52
54 assertEquals(123, toNumber("123 ")); 53 assertEquals(123, toNumber("123 "));
55 assertEquals(123, toNumber("123\n")); 54 assertEquals(123, toNumber("123\n"));
56 assertEquals(123, toNumber("123\r")); 55 assertEquals(123, toNumber("123\r"));
57 assertEquals(123, toNumber("123\t")); 56 assertEquals(123, toNumber("123\t"));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 assertEquals(15, toNumber("0XF")); 143 assertEquals(15, toNumber("0XF"));
145 144
146 assertEquals(0, toNumber("0x000")); 145 assertEquals(0, toNumber("0x000"));
147 assertEquals(-Infinity, 1 / toNumber("-0x000")); 146 assertEquals(-Infinity, 1 / toNumber("-0x000"));
148 assertEquals(0, toNumber("0x000" + repeat('0', 1000))); 147 assertEquals(0, toNumber("0x000" + repeat('0', 1000)));
149 assertEquals(9, toNumber("0x009")); 148 assertEquals(9, toNumber("0x009"));
150 assertEquals(10, toNumber("0x00a")); 149 assertEquals(10, toNumber("0x00a"));
151 assertEquals(10, toNumber("0x00A")); 150 assertEquals(10, toNumber("0x00A"));
152 assertEquals(15, toNumber("0x00f")); 151 assertEquals(15, toNumber("0x00f"));
153 assertEquals(15, toNumber("0x00F")); 152 assertEquals(15, toNumber("0x00F"));
153 assertEquals(15, toNumber("0x00F "));
154 assertEquals(Infinity, toNumber("0x" + repeat('0', 1000) + '1' 154 assertEquals(Infinity, toNumber("0x" + repeat('0', 1000) + '1'
155 + repeat('0', 1000))); 155 + repeat('0', 1000)));
156 assertEquals(-Infinity, toNumber("-0x1" + repeat('0', 1000))); 156 assertEquals(-Infinity, toNumber("-0x1" + repeat('0', 1000)));
157 157
158 assertEquals(0x1000000 * 0x10000000, toNumber("0x10000000000000"));
159 assertEquals(0x1000000 * 0x10000000 + 1, toNumber("0x10000000000001"));
160 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000000"));
161 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000001"));
162 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000007"));
163 assertEquals(0x10 * 0x1000000 * 0x10000000, toNumber("0x100000000000008"));
164 assertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
165 toNumber("0x100000000000009"));
166 assertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
167 toNumber("0x10000000000000F"));
168 assertEquals(0x10 * (0x1000000 * 0x10000000 + 1),
169 toNumber("0x100000000000010"));
170 assertEquals(0x100000000000 * 0x1000000 * 0x10000000,
171 toNumber("0x1000000000000000000000000"));
172 assertEquals(0x100000000000 * 0x1000000 * 0x10000000,
173 toNumber("0x1000000000000080000000000"));
174 assertEquals(0x100000000000 * (0x1000000 * 0x10000000 + 1),
175 toNumber("0x1000000000000080000000001"));
176 assertEquals(0x100000000000 * 0x1000000 * 0x10000000,
177 toNumber(" 0x1000000000000000000000000 "));
178
158 assertEquals(0, toNumber("00")); 179 assertEquals(0, toNumber("00"));
159 assertEquals(1, toNumber("01")); 180 assertEquals(1, toNumber("01"));
160 assertEquals(2, toNumber("02")); 181 assertEquals(2, toNumber("02"));
161 assertEquals(10, toNumber("010")); 182 assertEquals(10, toNumber("010"));
162 assertEquals(100, toNumber("0100")); 183 assertEquals(100, toNumber("0100"));
163 assertEquals(100, toNumber("000100")); 184 assertEquals(100, toNumber("000100"));
164 185
165 assertEquals(Infinity, toNumber("1e999"), "1e999"); 186 assertEquals(Infinity, toNumber("1e999"), "1e999");
166 assertEquals(-Infinity, toNumber("-1e999")); 187 assertEquals(-Infinity, toNumber("-1e999"));
167 assertEquals(0, toNumber("1e-999")); 188 assertEquals(0, toNumber("1e-999"));
168 assertEquals(0, toNumber("-1e-999")); 189 assertEquals(0, toNumber("-1e-999"));
169 assertEquals(Infinity, 1 / toNumber("1e-999"), "1e-999"); 190 assertEquals(Infinity, 1 / toNumber("1e-999"), "1e-999");
170 assertEquals(-Infinity, 1 / toNumber("-1e-999")); 191 assertEquals(-Infinity, 1 / toNumber("-1e-999"));
171 192
172 assertTrue(isNaN(toNumber("junk")), "junk"); 193 assertTrue(isNaN(toNumber("junk")), "junk");
173 assertTrue(isNaN(toNumber("100 junk")), "100 junk"); 194 assertTrue(isNaN(toNumber("100 junk")), "100 junk");
174 assertTrue(isNaN(toNumber("0x100 junk")), "0x100 junk"); 195 assertTrue(isNaN(toNumber("0x100 junk")), "0x100 junk");
175 assertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk"); 196 assertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk");
176 assertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk"); 197 assertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk");
177 assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk"); 198 assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk");
178 assertTrue(isNaN(toNumber("1e")), "1e"); 199 assertTrue(isNaN(toNumber("1e")), "1e");
179 assertTrue(isNaN(toNumber("1e ")), "1e_"); 200 assertTrue(isNaN(toNumber("1e ")), "1e_");
180 assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk"); 201 assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
OLDNEW
« no previous file with comments | « test/mjsunit/number-tostring.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698