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

Side by Side Diff: test/cctest/test-strtod.cc

Issue 798413003: Remove obsolete V8_INFINITY macro. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Svens smiley. Created 6 years 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
« no previous file with comments | « test/cctest/test-double.cc ('k') | test/cctest/test-types.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 CHECK_EQ(40000e-328, StrtodChar("30000", -328)); 193 CHECK_EQ(40000e-328, StrtodChar("30000", -328));
194 CHECK_EQ(0.0, StrtodChar("10000", -329)); 194 CHECK_EQ(0.0, StrtodChar("10000", -329));
195 CHECK_EQ(0.0, StrtodChar("90000", -329)); 195 CHECK_EQ(0.0, StrtodChar("90000", -329));
196 CHECK_EQ(0.0, StrtodChar("000000001", -325)); 196 CHECK_EQ(0.0, StrtodChar("000000001", -325));
197 CHECK_EQ(0.0, StrtodChar("000000001", -325)); 197 CHECK_EQ(0.0, StrtodChar("000000001", -325));
198 CHECK_EQ(0.0, StrtodChar("0000000020000", -328)); 198 CHECK_EQ(0.0, StrtodChar("0000000020000", -328));
199 CHECK_EQ(40000e-328, StrtodChar("00000030000", -328)); 199 CHECK_EQ(40000e-328, StrtodChar("00000030000", -328));
200 CHECK_EQ(0.0, StrtodChar("0000000010000", -329)); 200 CHECK_EQ(0.0, StrtodChar("0000000010000", -329));
201 CHECK_EQ(0.0, StrtodChar("0000000090000", -329)); 201 CHECK_EQ(0.0, StrtodChar("0000000090000", -329));
202 202
203 // It would be more readable to put the literals (and not V8_INFINITY) on the 203 // It would be more readable to put the literals (and not
204 // std::numeric_limits<double>::infinity()) on the
204 // left side (i.e. CHECK_EQ(1e309, StrtodChar("1", 309))), but then Gcc 205 // left side (i.e. CHECK_EQ(1e309, StrtodChar("1", 309))), but then Gcc
205 // complains that the floating constant exceeds range of 'double'. 206 // complains that the floating constant exceeds range of 'double'.
206 CHECK_EQ(V8_INFINITY, StrtodChar("1", 309)); 207 CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("1", 309));
207 CHECK_EQ(1e308, StrtodChar("1", 308)); 208 CHECK_EQ(1e308, StrtodChar("1", 308));
208 CHECK_EQ(1234e305, StrtodChar("1234", 305)); 209 CHECK_EQ(1234e305, StrtodChar("1234", 305));
209 CHECK_EQ(1234e304, StrtodChar("1234", 304)); 210 CHECK_EQ(1234e304, StrtodChar("1234", 304));
210 CHECK_EQ(V8_INFINITY, StrtodChar("18", 307)); 211 CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("18", 307));
211 CHECK_EQ(17e307, StrtodChar("17", 307)); 212 CHECK_EQ(17e307, StrtodChar("17", 307));
212 CHECK_EQ(V8_INFINITY, StrtodChar("0000001", 309)); 213 CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("0000001", 309));
213 CHECK_EQ(1e308, StrtodChar("00000001", 308)); 214 CHECK_EQ(1e308, StrtodChar("00000001", 308));
214 CHECK_EQ(1234e305, StrtodChar("00000001234", 305)); 215 CHECK_EQ(1234e305, StrtodChar("00000001234", 305));
215 CHECK_EQ(1234e304, StrtodChar("000000001234", 304)); 216 CHECK_EQ(1234e304, StrtodChar("000000001234", 304));
216 CHECK_EQ(V8_INFINITY, StrtodChar("0000000018", 307)); 217 CHECK_EQ(std::numeric_limits<double>::infinity(),
218 StrtodChar("0000000018", 307));
217 CHECK_EQ(17e307, StrtodChar("0000000017", 307)); 219 CHECK_EQ(17e307, StrtodChar("0000000017", 307));
218 CHECK_EQ(V8_INFINITY, StrtodChar("1000000", 303)); 220 CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("1000000", 303));
219 CHECK_EQ(1e308, StrtodChar("100000", 303)); 221 CHECK_EQ(1e308, StrtodChar("100000", 303));
220 CHECK_EQ(1234e305, StrtodChar("123400000", 300)); 222 CHECK_EQ(1234e305, StrtodChar("123400000", 300));
221 CHECK_EQ(1234e304, StrtodChar("123400000", 299)); 223 CHECK_EQ(1234e304, StrtodChar("123400000", 299));
222 CHECK_EQ(V8_INFINITY, StrtodChar("180000000", 300)); 224 CHECK_EQ(std::numeric_limits<double>::infinity(),
225 StrtodChar("180000000", 300));
223 CHECK_EQ(17e307, StrtodChar("170000000", 300)); 226 CHECK_EQ(17e307, StrtodChar("170000000", 300));
224 CHECK_EQ(V8_INFINITY, StrtodChar("00000001000000", 303)); 227 CHECK_EQ(std::numeric_limits<double>::infinity(),
228 StrtodChar("00000001000000", 303));
225 CHECK_EQ(1e308, StrtodChar("000000000000100000", 303)); 229 CHECK_EQ(1e308, StrtodChar("000000000000100000", 303));
226 CHECK_EQ(1234e305, StrtodChar("00000000123400000", 300)); 230 CHECK_EQ(1234e305, StrtodChar("00000000123400000", 300));
227 CHECK_EQ(1234e304, StrtodChar("0000000123400000", 299)); 231 CHECK_EQ(1234e304, StrtodChar("0000000123400000", 299));
228 CHECK_EQ(V8_INFINITY, StrtodChar("00000000180000000", 300)); 232 CHECK_EQ(std::numeric_limits<double>::infinity(),
233 StrtodChar("00000000180000000", 300));
229 CHECK_EQ(17e307, StrtodChar("00000000170000000", 300)); 234 CHECK_EQ(17e307, StrtodChar("00000000170000000", 300));
230 CHECK_EQ(1.7976931348623157E+308, StrtodChar("17976931348623157", 292)); 235 CHECK_EQ(1.7976931348623157E+308, StrtodChar("17976931348623157", 292));
231 CHECK_EQ(1.7976931348623158E+308, StrtodChar("17976931348623158", 292)); 236 CHECK_EQ(1.7976931348623158E+308, StrtodChar("17976931348623158", 292));
232 CHECK_EQ(V8_INFINITY, StrtodChar("17976931348623159", 292)); 237 CHECK_EQ(std::numeric_limits<double>::infinity(),
238 StrtodChar("17976931348623159", 292));
233 239
234 // The following number is the result of 89255.0/1e22. Both floating-point 240 // The following number is the result of 89255.0/1e22. Both floating-point
235 // numbers can be accurately represented with doubles. However on Linux,x86 241 // numbers can be accurately represented with doubles. However on Linux,x86
236 // the floating-point stack is set to 80bits and the double-rounding 242 // the floating-point stack is set to 80bits and the double-rounding
237 // introduces an error. 243 // introduces an error.
238 CHECK_EQ(89255e-22, StrtodChar("89255", -22)); 244 CHECK_EQ(89255e-22, StrtodChar("89255", -22));
239 245
240 // Some random values. 246 // Some random values.
241 CHECK_EQ(358416272e-33, StrtodChar("358416272", -33)); 247 CHECK_EQ(358416272e-33, StrtodChar("358416272", -33));
242 CHECK_EQ(104110013277974872254e-225, 248 CHECK_EQ(104110013277974872254e-225,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 DiyFp upper_boundary; 406 DiyFp upper_boundary;
401 Bignum input_digits; 407 Bignum input_digits;
402 input_digits.AssignDecimalString(buffer); 408 input_digits.AssignDecimalString(buffer);
403 if (to_check == 0.0) { 409 if (to_check == 0.0) {
404 const double kMinDouble = 4e-324; 410 const double kMinDouble = 4e-324;
405 // Check that the buffer*10^exponent < (0 + kMinDouble)/2. 411 // Check that the buffer*10^exponent < (0 + kMinDouble)/2.
406 Double d(kMinDouble); 412 Double d(kMinDouble);
407 d.NormalizedBoundaries(&lower_boundary, &upper_boundary); 413 d.NormalizedBoundaries(&lower_boundary, &upper_boundary);
408 return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) <= 0; 414 return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) <= 0;
409 } 415 }
410 if (to_check == V8_INFINITY) { 416 if (to_check == std::numeric_limits<double>::infinity()) {
411 const double kMaxDouble = 1.7976931348623157e308; 417 const double kMaxDouble = 1.7976931348623157e308;
412 // Check that the buffer*10^exponent >= boundary between kMaxDouble and inf. 418 // Check that the buffer*10^exponent >= boundary between kMaxDouble and inf.
413 Double d(kMaxDouble); 419 Double d(kMaxDouble);
414 d.NormalizedBoundaries(&lower_boundary, &upper_boundary); 420 d.NormalizedBoundaries(&lower_boundary, &upper_boundary);
415 return CompareBignumToDiyFp(input_digits, exponent, upper_boundary) >= 0; 421 return CompareBignumToDiyFp(input_digits, exponent, upper_boundary) >= 0;
416 } 422 }
417 Double d(to_check); 423 Double d(to_check);
418 d.NormalizedBoundaries(&lower_boundary, &upper_boundary); 424 d.NormalizedBoundaries(&lower_boundary, &upper_boundary);
419 if ((d.Significand() & 1) == 0) { 425 if ((d.Significand() & 1) == 0) {
420 return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) >= 0 && 426 return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) >= 0 &&
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 buffer[pos++] = rng.NextInt(10) + '0'; 477 buffer[pos++] = rng.NextInt(10) + '0';
472 } 478 }
473 int exponent = DeterministicRandom() % (308*2 + 1) - 308 - length; 479 int exponent = DeterministicRandom() % (308*2 + 1) - 308 - length;
474 buffer[pos] = '\0'; 480 buffer[pos] = '\0';
475 Vector<const char> vector(buffer, pos); 481 Vector<const char> vector(buffer, pos);
476 double strtod_result = Strtod(vector, exponent); 482 double strtod_result = Strtod(vector, exponent);
477 CHECK(CheckDouble(vector, exponent, strtod_result)); 483 CHECK(CheckDouble(vector, exponent, strtod_result));
478 } 484 }
479 } 485 }
480 } 486 }
OLDNEW
« no previous file with comments | « test/cctest/test-double.cc ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698