| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 template <typename NumberType> | 104 template <typename NumberType> |
| 105 static String indexOutsideRange(const char* name, NumberType given, NumberTy
pe lowerBound, BoundType lowerType, NumberType upperBound, BoundType upperType) | 105 static String indexOutsideRange(const char* name, NumberType given, NumberTy
pe lowerBound, BoundType lowerType, NumberType upperBound, BoundType upperType) |
| 106 { | 106 { |
| 107 StringBuilder result; | 107 StringBuilder result; |
| 108 result.append("The "); | 108 result.append("The "); |
| 109 result.append(name); | 109 result.append(name); |
| 110 result.append(" provided ("); | 110 result.append(" provided ("); |
| 111 result.append(formatNumber(given)); | 111 result.append(formatNumber(given)); |
| 112 result.append(") is outside the range "); | 112 result.append(") is outside the range "); |
| 113 result.append(lowerBound == ExclusiveBound ? '(' : '['); | 113 result.append(lowerType == ExclusiveBound ? '(' : '['); |
| 114 result.append(formatNumber(lowerBound)); | 114 result.append(formatNumber(lowerBound)); |
| 115 result.append(", "); | 115 result.append(", "); |
| 116 result.append(formatNumber(upperBound)); | 116 result.append(formatNumber(upperBound)); |
| 117 result.append(upperBound == ExclusiveBound ? ')' : ']'); | 117 result.append(upperType == ExclusiveBound ? ')' : ']'); |
| 118 result.append('.'); | 118 result.append('.'); |
| 119 return result.toString(); | 119 return result.toString(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 static String ordinalNumber(int number); | 123 static String ordinalNumber(int number); |
| 124 | 124 |
| 125 template <typename NumType> | 125 template <typename NumType> |
| 126 static String formatNumber(NumType number) | 126 static String formatNumber(NumType number) |
| 127 { | 127 { |
| 128 if (std::isnan(number)) | 128 if (std::isnan(number)) |
| 129 return "NaN"; | 129 return "NaN"; |
| 130 if (std::isinf(number)) | 130 if (std::isinf(number)) |
| 131 return number > 0 ? "Infinity" : "-Infinity"; | 131 return number > 0 ? "Infinity" : "-Infinity"; |
| 132 if (number > 1e20 || number < -1e20) | 132 if (number > 1e20 || number < -1e20) |
| 133 return String::format("%e", 1.0*number); | 133 return String::format("%e", 1.0*number); |
| 134 return String::number(number); | 134 return String::number(number); |
| 135 } | 135 } |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 } // namespace WebCore | 138 } // namespace WebCore |
| 139 | 139 |
| 140 #endif // ExceptionMessages_h | 140 #endif // ExceptionMessages_h |
| OLD | NEW |