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

Side by Side Diff: tests/corelib/math_test.dart

Issue 10850034: Rename BadNumberFormatException -> FormatException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years, 4 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 | « tests/corelib/math_parse_double_test.dart ('k') | tests/language/arithmetic_test.dart » ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class MathTest { 5 class MathTest {
6 static void testConstants() { 6 static void testConstants() {
7 // Source for mathematical constants is Wolfram Alpha. 7 // Source for mathematical constants is Wolfram Alpha.
8 Expect.equals(2.7182818284590452353602874713526624977572470936999595749669, 8 Expect.equals(2.7182818284590452353602874713526624977572470936999595749669,
9 Math.E); 9 Math.E);
10 Expect.equals(2.3025850929940456840179914546843642076011014886287729760333, 10 Expect.equals(2.3025850929940456840179914546843642076011014886287729760333,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 checkVeryClose(Math.LN10, Math.log(10.0)); 141 checkVeryClose(Math.LN10, Math.log(10.0));
142 checkVeryClose(Math.LN2, Math.log(2.0)); 142 checkVeryClose(Math.LN2, Math.log(2.0));
143 } 143 }
144 144
145 static void testPow() { 145 static void testPow() {
146 checkVeryClose(16.0, Math.pow(4.0, 2.0)); 146 checkVeryClose(16.0, Math.pow(4.0, 2.0));
147 checkVeryClose(Math.SQRT2, Math.pow(2.0, 0.5)); 147 checkVeryClose(Math.SQRT2, Math.pow(2.0, 0.5));
148 checkVeryClose(Math.SQRT1_2, Math.pow(0.5, 0.5)); 148 checkVeryClose(Math.SQRT1_2, Math.pow(0.5, 0.5));
149 } 149 }
150 150
151 static bool parseIntThrowsBadNumberFormatException(str) { 151 static bool parseIntThrowsFormatException(str) {
152 try { 152 try {
153 Math.parseInt(str); 153 Math.parseInt(str);
154 return false; 154 return false;
155 } catch (BadNumberFormatException e) { 155 } catch (FormatException e) {
156 return true; 156 return true;
157 } 157 }
158 } 158 }
159 159
160 static void testParseInt() { 160 static void testParseInt() {
161 Expect.equals(499, Math.parseInt("499")); 161 Expect.equals(499, Math.parseInt("499"));
162 Expect.equals(499, Math.parseInt("+499")); 162 Expect.equals(499, Math.parseInt("+499"));
163 Expect.equals(-499, Math.parseInt("-499")); 163 Expect.equals(-499, Math.parseInt("-499"));
164 Expect.equals(499, Math.parseInt(" 499 ")); 164 Expect.equals(499, Math.parseInt(" 499 "));
165 Expect.equals(499, Math.parseInt(" +499 ")); 165 Expect.equals(499, Math.parseInt(" +499 "));
(...skipping 29 matching lines...) Expand all
195 Expect.equals(0xABCDEF, Math.parseInt(" 0x00000ABCDEF ")); 195 Expect.equals(0xABCDEF, Math.parseInt(" 0x00000ABCDEF "));
196 Expect.equals(-0xabcdef, Math.parseInt(" -0x00000abcdef ")); 196 Expect.equals(-0xabcdef, Math.parseInt(" -0x00000abcdef "));
197 Expect.equals(-0xABCDEF, Math.parseInt(" -0x00000ABCDEF ")); 197 Expect.equals(-0xABCDEF, Math.parseInt(" -0x00000ABCDEF "));
198 Expect.equals(10, Math.parseInt("010")); 198 Expect.equals(10, Math.parseInt("010"));
199 Expect.equals(-10, Math.parseInt("-010")); 199 Expect.equals(-10, Math.parseInt("-010"));
200 Expect.equals(10, Math.parseInt(" 010 ")); 200 Expect.equals(10, Math.parseInt(" 010 "));
201 Expect.equals(-10, Math.parseInt(" -010 ")); 201 Expect.equals(-10, Math.parseInt(" -010 "));
202 Expect.equals(9, Math.parseInt("09")); 202 Expect.equals(9, Math.parseInt("09"));
203 Expect.equals(9, Math.parseInt(" 09 ")); 203 Expect.equals(9, Math.parseInt(" 09 "));
204 Expect.equals(-9, Math.parseInt("-09")); 204 Expect.equals(-9, Math.parseInt("-09"));
205 Expect.equals(true, parseIntThrowsBadNumberFormatException("1b")); 205 Expect.equals(true, parseIntThrowsFormatException("1b"));
206 Expect.equals(true, parseIntThrowsBadNumberFormatException(" 1b ")); 206 Expect.equals(true, parseIntThrowsFormatException(" 1b "));
207 Expect.equals(true, parseIntThrowsBadNumberFormatException(" 1 b ")); 207 Expect.equals(true, parseIntThrowsFormatException(" 1 b "));
208 Expect.equals(true, parseIntThrowsBadNumberFormatException("1e2")); 208 Expect.equals(true, parseIntThrowsFormatException("1e2"));
209 Expect.equals(true, parseIntThrowsBadNumberFormatException(" 1e2 ")); 209 Expect.equals(true, parseIntThrowsFormatException(" 1e2 "));
210 Expect.equals(true, parseIntThrowsBadNumberFormatException("00x12")); 210 Expect.equals(true, parseIntThrowsFormatException("00x12"));
211 Expect.equals(true, parseIntThrowsBadNumberFormatException(" 00x12 ")); 211 Expect.equals(true, parseIntThrowsFormatException(" 00x12 "));
212 Expect.equals(true, parseIntThrowsBadNumberFormatException("-1b")); 212 Expect.equals(true, parseIntThrowsFormatException("-1b"));
213 Expect.equals(true, parseIntThrowsBadNumberFormatException(" -1b ")); 213 Expect.equals(true, parseIntThrowsFormatException(" -1b "));
214 Expect.equals(true, parseIntThrowsBadNumberFormatException(" -1 b ")); 214 Expect.equals(true, parseIntThrowsFormatException(" -1 b "));
215 Expect.equals(true, parseIntThrowsBadNumberFormatException("-1e2")); 215 Expect.equals(true, parseIntThrowsFormatException("-1e2"));
216 Expect.equals(true, parseIntThrowsBadNumberFormatException(" -1e2 ")); 216 Expect.equals(true, parseIntThrowsFormatException(" -1e2 "));
217 Expect.equals(true, parseIntThrowsBadNumberFormatException("-00x12")); 217 Expect.equals(true, parseIntThrowsFormatException("-00x12"));
218 Expect.equals(true, parseIntThrowsBadNumberFormatException(" -00x12 ")); 218 Expect.equals(true, parseIntThrowsFormatException(" -00x12 "));
219 Expect.equals(true, parseIntThrowsBadNumberFormatException(" -00x12 ")); 219 Expect.equals(true, parseIntThrowsFormatException(" -00x12 "));
220 Expect.equals(true, parseIntThrowsBadNumberFormatException("0x0x12")); 220 Expect.equals(true, parseIntThrowsFormatException("0x0x12"));
221 Expect.equals(true, parseIntThrowsBadNumberFormatException("0.1")); 221 Expect.equals(true, parseIntThrowsFormatException("0.1"));
222 Expect.equals(true, parseIntThrowsBadNumberFormatException("0x3.1")); 222 Expect.equals(true, parseIntThrowsFormatException("0x3.1"));
223 Expect.equals(true, parseIntThrowsBadNumberFormatException("5.")); 223 Expect.equals(true, parseIntThrowsFormatException("5."));
224 Expect.equals(true, parseIntThrowsBadNumberFormatException("+-5")); 224 Expect.equals(true, parseIntThrowsFormatException("+-5"));
225 Expect.equals(true, parseIntThrowsBadNumberFormatException("-+5")); 225 Expect.equals(true, parseIntThrowsFormatException("-+5"));
226 Expect.equals(true, parseIntThrowsBadNumberFormatException("--5")); 226 Expect.equals(true, parseIntThrowsFormatException("--5"));
227 Expect.equals(true, parseIntThrowsBadNumberFormatException("++5")); 227 Expect.equals(true, parseIntThrowsFormatException("++5"));
228 Expect.equals(true, parseIntThrowsBadNumberFormatException("+ 5")); 228 Expect.equals(true, parseIntThrowsFormatException("+ 5"));
229 Expect.equals(true, parseIntThrowsBadNumberFormatException("- 5")); 229 Expect.equals(true, parseIntThrowsFormatException("- 5"));
230 Expect.equals(true, parseIntThrowsBadNumberFormatException("")); 230 Expect.equals(true, parseIntThrowsFormatException(""));
231 Expect.equals(true, parseIntThrowsBadNumberFormatException(" ")); 231 Expect.equals(true, parseIntThrowsFormatException(" "));
232 Expect.equals(true, parseIntThrowsBadNumberFormatException("+0x1234567890")) ; 232 Expect.equals(true, parseIntThrowsFormatException("+0x1234567890"));
233 Expect.equals(true, parseIntThrowsBadNumberFormatException(" +0x1234567890 ")); 233 Expect.equals(true, parseIntThrowsFormatException(" +0x1234567890 "));
234 Expect.equals(true, parseIntThrowsBadNumberFormatException("+0x100")); 234 Expect.equals(true, parseIntThrowsFormatException("+0x100"));
235 Expect.equals(true, parseIntThrowsBadNumberFormatException(" +0x100 ")); 235 Expect.equals(true, parseIntThrowsFormatException(" +0x100 "));
236 } 236 }
237 237
238 static testMain() { 238 static testMain() {
239 testConstants(); 239 testConstants();
240 testSin(); 240 testSin();
241 testCos(); 241 testCos();
242 testTan(); 242 testTan();
243 testAsin(); 243 testAsin();
244 testAcos(); 244 testAcos();
245 testAtan(); 245 testAtan();
246 testAtan2(); 246 testAtan2();
247 testSqrt(); 247 testSqrt();
248 testLog(); 248 testLog();
249 testExp(); 249 testExp();
250 testPow(); 250 testPow();
251 testParseInt(); 251 testParseInt();
252 } 252 }
253 } 253 }
254 254
255 main() { 255 main() {
256 MathTest.testMain(); 256 MathTest.testMain();
257 } 257 }
OLDNEW
« no previous file with comments | « tests/corelib/math_parse_double_test.dart ('k') | tests/language/arithmetic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698