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

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

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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/corelib/min_max_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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // We temporarily test both the new math library and the old Math
6 // class. This can easily be simplified once we get rid of the Math
7 // class entirely.
8 #library('math_test');
9 #import('dart:math', prefix: 'math');
10
11 class MathTest {
12 static void testConstants() {
13 // Source for mathematical constants is Wolfram Alpha.
14 Expect.equals(2.7182818284590452353602874713526624977572470936999595749669,
15 Math.E);
16 Expect.equals(2.3025850929940456840179914546843642076011014886287729760333,
17 Math.LN10);
18 Expect.equals(0.6931471805599453094172321214581765680755001343602552541206,
19 Math.LN2);
20 Expect.equals(1.4426950408889634073599246810018921374266459541529859341354,
21 Math.LOG2E);
22 Expect.equals(0.4342944819032518276511289189166050822943970058036665661144,
23 Math.LOG10E);
24 Expect.equals(3.1415926535897932384626433832795028841971693993751058209749,
25 Math.PI);
26 Expect.equals(0.7071067811865475244008443621048490392848359376884740365883,
27 Math.SQRT1_2);
28 Expect.equals(1.4142135623730950488016887242096980785696718753769480731766,
29 Math.SQRT2);
30 }
31
32 static checkClose(double a, double b, EPSILON) {
33 Expect.equals(true, a - EPSILON <= b);
34 Expect.equals(true, b <= a + EPSILON);
35 }
36
37 static void testSin() {
38 // Given the imprecision of PI we can't expect better results than this.
39 final double EPSILON = 1e-15;
40 checkClose(0.0, Math.sin(0.0), EPSILON);
41 checkClose(0.0, Math.sin(Math.PI), EPSILON);
42 checkClose(0.0, Math.sin(2.0 * Math.PI), EPSILON);
43 checkClose(1.0, Math.sin(Math.PI / 2.0), EPSILON);
44 checkClose(-1.0, Math.sin(Math.PI * (3.0 / 2.0)), EPSILON);
45 }
46
47 static void testCos() {
48 // Given the imprecision of PI we can't expect better results than this.
49 final double EPSILON = 1e-15;
50 checkClose(1.0, Math.cos(0.0), EPSILON);
51 checkClose(-1.0, Math.cos(Math.PI), EPSILON);
52 checkClose(1.0, Math.cos(2.0 * Math.PI), EPSILON);
53 checkClose(0.0, Math.cos(Math.PI / 2.0), EPSILON);
54 checkClose(0.0, Math.cos(Math.PI * (3.0 / 2.0)), EPSILON);
55 }
56
57 static void testTan() {
58 // Given the imprecision of PI we can't expect better results than this.
59 final double EPSILON = 1e-15;
60 checkClose(0.0, Math.tan(0.0), EPSILON);
61 checkClose(0.0, Math.tan(Math.PI), EPSILON);
62 checkClose(0.0, Math.tan(2.0 * Math.PI), EPSILON);
63 checkClose(1.0, Math.tan(Math.PI / 4.0), EPSILON);
64 }
65
66 static void testAsin() {
67 // Given the imprecision of PI we can't expect better results than this.
68 final double EPSILON = 1e-15;
69 checkClose(0.0, Math.asin(0.0), EPSILON);
70 checkClose(Math.PI / 2.0, Math.asin(1.0), EPSILON);
71 checkClose(-Math.PI / 2.0, Math.asin(-1.0), EPSILON);
72 }
73
74
75 static void testAcos() {
76 // Given the imprecision of PI we can't expect better results than this.
77 final double EPSILON = 1e-15;
78 checkClose(0.0, Math.acos(1.0), EPSILON);
79 checkClose(Math.PI, Math.acos(-1.0), EPSILON);
80 checkClose(Math.PI / 2.0, Math.acos(0.0), EPSILON);
81 }
82
83 static void testAtan() {
84 // Given the imprecision of PI we can't expect better results than this.
85 final double EPSILON = 1e-15;
86 checkClose(0.0, Math.atan(0.0), EPSILON);
87 checkClose(Math.PI / 4.0, Math.atan(1.0), EPSILON);
88 checkClose(-Math.PI / 4.0, Math.atan(-1.0), EPSILON);
89 }
90
91 static void testAtan2() {
92 // Given the imprecision of PI we can't expect better results than this.
93 final double EPSILON = 1e-15;
94 checkClose(0.0, Math.atan2(0.0, 5.0), EPSILON);
95 checkClose(Math.PI / 4.0, Math.atan2(2.0, 2.0), EPSILON);
96 checkClose(3 * Math.PI / 4.0, Math.atan2(0.5, -0.5), EPSILON);
97 checkClose(-3 * Math.PI / 4.0, Math.atan2(-2.5, -2.5), EPSILON);
98 }
99
100 static checkVeryClose(double a, double b) {
101 // We find a ulp (unit in the last place) by shifting the original number
102 // to the right. This only works if we are not too close to infinity or if
103 // we work with denormals.
104 // We special case or 0.0, but not for infinity.
105 if (a == 0.0) {
106 final minimalDouble = 4.9406564584124654e-324;
107 Expect.equals(true, b.abs() <= minimalDouble);
108 return;
109 }
110 if (b == 0.0) {
111 // No need to look if they are close. Otherwise the check for 'a' above
112 // whould have triggered.
113 Expect.equals(a, b);
114 }
115 final double shiftRightBy52 = 2.220446049250313080847263336181640625e-16;
116 final double shiftedA = (a * shiftRightBy52).abs();
117 // Compared to 'a', 'shiftedA' is now ~1-2 ulp.
118
119 final double limitLow = a - shiftedA;
120 final double limitHigh = a + shiftedA;
121 Expect.equals(false, a == limitLow);
122 Expect.equals(false, a == limitHigh);
123 Expect.equals(true, limitLow <= b);
124 Expect.equals(true, b <= limitHigh);
125 }
126
127 static void testSqrt() {
128 checkVeryClose(2.0, Math.sqrt(4.0));
129 checkVeryClose(Math.SQRT2, Math.sqrt(2.0));
130 checkVeryClose(Math.SQRT1_2, Math.sqrt(0.5));
131 checkVeryClose(1e50, Math.sqrt(1e100));
132 checkVeryClose(1.1111111061110855443054405046358901279277111935183977e56,
133 Math.sqrt(12345678901234e99));
134 }
135
136 static void testExp() {
137 checkVeryClose(Math.E, Math.exp(1.0));
138 final EPSILON = 1e-15;
139 checkClose(10.0, Math.exp(Math.LN10), EPSILON);
140 checkClose(2.0, Math.exp(Math.LN2), EPSILON);
141 }
142
143 static void testLog() {
144 // Even though E is imprecise, it is good enough to get really close to 1.
145 // We still provide an epsilon.
146 checkClose(1.0, Math.log(Math.E), 1e-16);
147 checkVeryClose(Math.LN10, Math.log(10.0));
148 checkVeryClose(Math.LN2, Math.log(2.0));
149 }
150
151 static void testPow() {
152 checkVeryClose(16.0, Math.pow(4.0, 2.0));
153 checkVeryClose(Math.SQRT2, Math.pow(2.0, 0.5));
154 checkVeryClose(Math.SQRT1_2, Math.pow(0.5, 0.5));
155 }
156
157 static bool parseIntThrowsFormatException(str) {
158 try {
159 Math.parseInt(str);
160 return false;
161 } catch (FormatException e) {
162 return true;
163 }
164 }
165
166 static void testParseInt() {
167 Expect.equals(499, Math.parseInt("499"));
168 Expect.equals(499, Math.parseInt("+499"));
169 Expect.equals(-499, Math.parseInt("-499"));
170 Expect.equals(499, Math.parseInt(" 499 "));
171 Expect.equals(499, Math.parseInt(" +499 "));
172 Expect.equals(-499, Math.parseInt(" -499 "));
173 Expect.equals(0, Math.parseInt("0"));
174 Expect.equals(0, Math.parseInt("+0"));
175 Expect.equals(0, Math.parseInt("-0"));
176 Expect.equals(0, Math.parseInt(" 0 "));
177 Expect.equals(0, Math.parseInt(" +0 "));
178 Expect.equals(0, Math.parseInt(" -0 "));
179 Expect.equals(0x1234567890, Math.parseInt("0x1234567890"));
180 Expect.equals(-0x1234567890, Math.parseInt("-0x1234567890"));
181 Expect.equals(0x1234567890, Math.parseInt(" 0x1234567890 "));
182 Expect.equals(-0x1234567890, Math.parseInt(" -0x1234567890 "));
183 Expect.equals(256, Math.parseInt("0x100"));
184 Expect.equals(-256, Math.parseInt("-0x100"));
185 Expect.equals(256, Math.parseInt(" 0x100 "));
186 Expect.equals(-256, Math.parseInt(" -0x100 "));
187 Expect.equals(0xabcdef, Math.parseInt("0xabcdef"));
188 Expect.equals(0xABCDEF, Math.parseInt("0xABCDEF"));
189 Expect.equals(0xabcdef, Math.parseInt("0xabCDEf"));
190 Expect.equals(-0xabcdef, Math.parseInt("-0xabcdef"));
191 Expect.equals(-0xABCDEF, Math.parseInt("-0xABCDEF"));
192 Expect.equals(0xabcdef, Math.parseInt(" 0xabcdef "));
193 Expect.equals(0xABCDEF, Math.parseInt(" 0xABCDEF "));
194 Expect.equals(-0xabcdef, Math.parseInt(" -0xabcdef "));
195 Expect.equals(-0xABCDEF, Math.parseInt(" -0xABCDEF "));
196 Expect.equals(0xabcdef, Math.parseInt("0x00000abcdef"));
197 Expect.equals(0xABCDEF, Math.parseInt("0x00000ABCDEF"));
198 Expect.equals(-0xabcdef, Math.parseInt("-0x00000abcdef"));
199 Expect.equals(-0xABCDEF, Math.parseInt("-0x00000ABCDEF"));
200 Expect.equals(0xabcdef, Math.parseInt(" 0x00000abcdef "));
201 Expect.equals(0xABCDEF, Math.parseInt(" 0x00000ABCDEF "));
202 Expect.equals(-0xabcdef, Math.parseInt(" -0x00000abcdef "));
203 Expect.equals(-0xABCDEF, Math.parseInt(" -0x00000ABCDEF "));
204 Expect.equals(10, Math.parseInt("010"));
205 Expect.equals(-10, Math.parseInt("-010"));
206 Expect.equals(10, Math.parseInt(" 010 "));
207 Expect.equals(-10, Math.parseInt(" -010 "));
208 Expect.equals(9, Math.parseInt("09"));
209 Expect.equals(9, Math.parseInt(" 09 "));
210 Expect.equals(-9, Math.parseInt("-09"));
211 Expect.equals(true, parseIntThrowsFormatException("1b"));
212 Expect.equals(true, parseIntThrowsFormatException(" 1b "));
213 Expect.equals(true, parseIntThrowsFormatException(" 1 b "));
214 Expect.equals(true, parseIntThrowsFormatException("1e2"));
215 Expect.equals(true, parseIntThrowsFormatException(" 1e2 "));
216 Expect.equals(true, parseIntThrowsFormatException("00x12"));
217 Expect.equals(true, parseIntThrowsFormatException(" 00x12 "));
218 Expect.equals(true, parseIntThrowsFormatException("-1b"));
219 Expect.equals(true, parseIntThrowsFormatException(" -1b "));
220 Expect.equals(true, parseIntThrowsFormatException(" -1 b "));
221 Expect.equals(true, parseIntThrowsFormatException("-1e2"));
222 Expect.equals(true, parseIntThrowsFormatException(" -1e2 "));
223 Expect.equals(true, parseIntThrowsFormatException("-00x12"));
224 Expect.equals(true, parseIntThrowsFormatException(" -00x12 "));
225 Expect.equals(true, parseIntThrowsFormatException(" -00x12 "));
226 Expect.equals(true, parseIntThrowsFormatException("0x0x12"));
227 Expect.equals(true, parseIntThrowsFormatException("0.1"));
228 Expect.equals(true, parseIntThrowsFormatException("0x3.1"));
229 Expect.equals(true, parseIntThrowsFormatException("5."));
230 Expect.equals(true, parseIntThrowsFormatException("+-5"));
231 Expect.equals(true, parseIntThrowsFormatException("-+5"));
232 Expect.equals(true, parseIntThrowsFormatException("--5"));
233 Expect.equals(true, parseIntThrowsFormatException("++5"));
234 Expect.equals(true, parseIntThrowsFormatException("+ 5"));
235 Expect.equals(true, parseIntThrowsFormatException("- 5"));
236 Expect.equals(true, parseIntThrowsFormatException(""));
237 Expect.equals(true, parseIntThrowsFormatException(" "));
238 Expect.equals(true, parseIntThrowsFormatException("+0x1234567890"));
239 Expect.equals(true, parseIntThrowsFormatException(" +0x1234567890 "));
240 Expect.equals(true, parseIntThrowsFormatException("+0x100"));
241 Expect.equals(true, parseIntThrowsFormatException(" +0x100 "));
242 }
243
244 static testMain() {
245 testConstants();
246 testSin();
247 testCos();
248 testTan();
249 testAsin();
250 testAcos();
251 testAtan();
252 testAtan2();
253 testSqrt();
254 testLog();
255 testExp();
256 testPow();
257 testParseInt();
258 }
259 }
260
261 class MathLibraryTest {
262 static void testConstants() {
263 // Source for mathematical constants is Wolfram Alpha.
264 Expect.equals(2.7182818284590452353602874713526624977572470936999595749669,
265 math.E);
266 Expect.equals(2.3025850929940456840179914546843642076011014886287729760333,
267 math.LN10);
268 Expect.equals(0.6931471805599453094172321214581765680755001343602552541206,
269 math.LN2);
270 Expect.equals(1.4426950408889634073599246810018921374266459541529859341354,
271 math.LOG2E);
272 Expect.equals(0.4342944819032518276511289189166050822943970058036665661144,
273 math.LOG10E);
274 Expect.equals(3.1415926535897932384626433832795028841971693993751058209749,
275 math.PI);
276 Expect.equals(0.7071067811865475244008443621048490392848359376884740365883,
277 math.SQRT1_2);
278 Expect.equals(1.4142135623730950488016887242096980785696718753769480731766,
279 math.SQRT2);
280 }
281
282 static checkClose(double a, double b, EPSILON) {
283 Expect.equals(true, a - EPSILON <= b);
284 Expect.equals(true, b <= a + EPSILON);
285 }
286
287 static void testSin() {
288 // Given the imprecision of PI we can't expect better results than this.
289 final double EPSILON = 1e-15;
290 checkClose(0.0, math.sin(0.0), EPSILON);
291 checkClose(0.0, math.sin(math.PI), EPSILON);
292 checkClose(0.0, math.sin(2.0 * math.PI), EPSILON);
293 checkClose(1.0, math.sin(math.PI / 2.0), EPSILON);
294 checkClose(-1.0, math.sin(math.PI * (3.0 / 2.0)), EPSILON);
295 }
296
297 static void testCos() {
298 // Given the imprecision of PI we can't expect better results than this.
299 final double EPSILON = 1e-15;
300 checkClose(1.0, math.cos(0.0), EPSILON);
301 checkClose(-1.0, math.cos(math.PI), EPSILON);
302 checkClose(1.0, math.cos(2.0 * math.PI), EPSILON);
303 checkClose(0.0, math.cos(math.PI / 2.0), EPSILON);
304 checkClose(0.0, math.cos(math.PI * (3.0 / 2.0)), EPSILON);
305 }
306
307 static void testTan() {
308 // Given the imprecision of PI we can't expect better results than this.
309 final double EPSILON = 1e-15;
310 checkClose(0.0, math.tan(0.0), EPSILON);
311 checkClose(0.0, math.tan(math.PI), EPSILON);
312 checkClose(0.0, math.tan(2.0 * math.PI), EPSILON);
313 checkClose(1.0, math.tan(math.PI / 4.0), EPSILON);
314 }
315
316 static void testAsin() {
317 // Given the imprecision of PI we can't expect better results than this.
318 final double EPSILON = 1e-15;
319 checkClose(0.0, math.asin(0.0), EPSILON);
320 checkClose(math.PI / 2.0, math.asin(1.0), EPSILON);
321 checkClose(-math.PI / 2.0, math.asin(-1.0), EPSILON);
322 }
323
324
325 static void testAcos() {
326 // Given the imprecision of PI we can't expect better results than this.
327 final double EPSILON = 1e-15;
328 checkClose(0.0, math.acos(1.0), EPSILON);
329 checkClose(math.PI, math.acos(-1.0), EPSILON);
330 checkClose(math.PI / 2.0, math.acos(0.0), EPSILON);
331 }
332
333 static void testAtan() {
334 // Given the imprecision of PI we can't expect better results than this.
335 final double EPSILON = 1e-15;
336 checkClose(0.0, math.atan(0.0), EPSILON);
337 checkClose(math.PI / 4.0, math.atan(1.0), EPSILON);
338 checkClose(-math.PI / 4.0, math.atan(-1.0), EPSILON);
339 }
340
341 static void testAtan2() {
342 // Given the imprecision of PI we can't expect better results than this.
343 final double EPSILON = 1e-15;
344 checkClose(0.0, math.atan2(0.0, 5.0), EPSILON);
345 checkClose(math.PI / 4.0, math.atan2(2.0, 2.0), EPSILON);
346 checkClose(3 * math.PI / 4.0, math.atan2(0.5, -0.5), EPSILON);
347 checkClose(-3 * math.PI / 4.0, math.atan2(-2.5, -2.5), EPSILON);
348 }
349
350 static checkVeryClose(double a, double b) {
351 // We find a ulp (unit in the last place) by shifting the original number
352 // to the right. This only works if we are not too close to infinity or if
353 // we work with denormals.
354 // We special case or 0.0, but not for infinity.
355 if (a == 0.0) {
356 final minimalDouble = 4.9406564584124654e-324;
357 Expect.equals(true, b.abs() <= minimalDouble);
358 return;
359 }
360 if (b == 0.0) {
361 // No need to look if they are close. Otherwise the check for 'a' above
362 // whould have triggered.
363 Expect.equals(a, b);
364 }
365 final double shiftRightBy52 = 2.220446049250313080847263336181640625e-16;
366 final double shiftedA = (a * shiftRightBy52).abs();
367 // Compared to 'a', 'shiftedA' is now ~1-2 ulp.
368
369 final double limitLow = a - shiftedA;
370 final double limitHigh = a + shiftedA;
371 Expect.equals(false, a == limitLow);
372 Expect.equals(false, a == limitHigh);
373 Expect.equals(true, limitLow <= b);
374 Expect.equals(true, b <= limitHigh);
375 }
376
377 static void testSqrt() {
378 checkVeryClose(2.0, math.sqrt(4.0));
379 checkVeryClose(math.SQRT2, math.sqrt(2.0));
380 checkVeryClose(math.SQRT1_2, math.sqrt(0.5));
381 checkVeryClose(1e50, math.sqrt(1e100));
382 checkVeryClose(1.1111111061110855443054405046358901279277111935183977e56,
383 math.sqrt(12345678901234e99));
384 }
385
386 static void testExp() {
387 checkVeryClose(math.E, math.exp(1.0));
388 final EPSILON = 1e-15;
389 checkClose(10.0, math.exp(math.LN10), EPSILON);
390 checkClose(2.0, math.exp(math.LN2), EPSILON);
391 }
392
393 static void testLog() {
394 // Even though E is imprecise, it is good enough to get really close to 1.
395 // We still provide an epsilon.
396 checkClose(1.0, math.log(math.E), 1e-16);
397 checkVeryClose(math.LN10, math.log(10.0));
398 checkVeryClose(math.LN2, math.log(2.0));
399 }
400
401 static void testPow() {
402 checkVeryClose(16.0, math.pow(4.0, 2.0));
403 checkVeryClose(math.SQRT2, math.pow(2.0, 0.5));
404 checkVeryClose(math.SQRT1_2, math.pow(0.5, 0.5));
405 }
406
407 static bool parseIntThrowsFormatException(str) {
408 try {
409 math.parseInt(str);
410 return false;
411 } catch (FormatException e) {
412 return true;
413 }
414 }
415
416 static void testParseInt() {
417 Expect.equals(499, math.parseInt("499"));
418 Expect.equals(499, math.parseInt("+499"));
419 Expect.equals(-499, math.parseInt("-499"));
420 Expect.equals(499, math.parseInt(" 499 "));
421 Expect.equals(499, math.parseInt(" +499 "));
422 Expect.equals(-499, math.parseInt(" -499 "));
423 Expect.equals(0, math.parseInt("0"));
424 Expect.equals(0, math.parseInt("+0"));
425 Expect.equals(0, math.parseInt("-0"));
426 Expect.equals(0, math.parseInt(" 0 "));
427 Expect.equals(0, math.parseInt(" +0 "));
428 Expect.equals(0, math.parseInt(" -0 "));
429 Expect.equals(0x1234567890, math.parseInt("0x1234567890"));
430 Expect.equals(-0x1234567890, math.parseInt("-0x1234567890"));
431 Expect.equals(0x1234567890, math.parseInt(" 0x1234567890 "));
432 Expect.equals(-0x1234567890, math.parseInt(" -0x1234567890 "));
433 Expect.equals(256, math.parseInt("0x100"));
434 Expect.equals(-256, math.parseInt("-0x100"));
435 Expect.equals(256, math.parseInt(" 0x100 "));
436 Expect.equals(-256, math.parseInt(" -0x100 "));
437 Expect.equals(0xabcdef, math.parseInt("0xabcdef"));
438 Expect.equals(0xABCDEF, math.parseInt("0xABCDEF"));
439 Expect.equals(0xabcdef, math.parseInt("0xabCDEf"));
440 Expect.equals(-0xabcdef, math.parseInt("-0xabcdef"));
441 Expect.equals(-0xABCDEF, math.parseInt("-0xABCDEF"));
442 Expect.equals(0xabcdef, math.parseInt(" 0xabcdef "));
443 Expect.equals(0xABCDEF, math.parseInt(" 0xABCDEF "));
444 Expect.equals(-0xabcdef, math.parseInt(" -0xabcdef "));
445 Expect.equals(-0xABCDEF, math.parseInt(" -0xABCDEF "));
446 Expect.equals(0xabcdef, math.parseInt("0x00000abcdef"));
447 Expect.equals(0xABCDEF, math.parseInt("0x00000ABCDEF"));
448 Expect.equals(-0xabcdef, math.parseInt("-0x00000abcdef"));
449 Expect.equals(-0xABCDEF, math.parseInt("-0x00000ABCDEF"));
450 Expect.equals(0xabcdef, math.parseInt(" 0x00000abcdef "));
451 Expect.equals(0xABCDEF, math.parseInt(" 0x00000ABCDEF "));
452 Expect.equals(-0xabcdef, math.parseInt(" -0x00000abcdef "));
453 Expect.equals(-0xABCDEF, math.parseInt(" -0x00000ABCDEF "));
454 Expect.equals(10, math.parseInt("010"));
455 Expect.equals(-10, math.parseInt("-010"));
456 Expect.equals(10, math.parseInt(" 010 "));
457 Expect.equals(-10, math.parseInt(" -010 "));
458 Expect.equals(9, math.parseInt("09"));
459 Expect.equals(9, math.parseInt(" 09 "));
460 Expect.equals(-9, math.parseInt("-09"));
461 Expect.equals(true, parseIntThrowsFormatException("1b"));
462 Expect.equals(true, parseIntThrowsFormatException(" 1b "));
463 Expect.equals(true, parseIntThrowsFormatException(" 1 b "));
464 Expect.equals(true, parseIntThrowsFormatException("1e2"));
465 Expect.equals(true, parseIntThrowsFormatException(" 1e2 "));
466 Expect.equals(true, parseIntThrowsFormatException("00x12"));
467 Expect.equals(true, parseIntThrowsFormatException(" 00x12 "));
468 Expect.equals(true, parseIntThrowsFormatException("-1b"));
469 Expect.equals(true, parseIntThrowsFormatException(" -1b "));
470 Expect.equals(true, parseIntThrowsFormatException(" -1 b "));
471 Expect.equals(true, parseIntThrowsFormatException("-1e2"));
472 Expect.equals(true, parseIntThrowsFormatException(" -1e2 "));
473 Expect.equals(true, parseIntThrowsFormatException("-00x12"));
474 Expect.equals(true, parseIntThrowsFormatException(" -00x12 "));
475 Expect.equals(true, parseIntThrowsFormatException(" -00x12 "));
476 Expect.equals(true, parseIntThrowsFormatException("0x0x12"));
477 Expect.equals(true, parseIntThrowsFormatException("0.1"));
478 Expect.equals(true, parseIntThrowsFormatException("0x3.1"));
479 Expect.equals(true, parseIntThrowsFormatException("5."));
480 Expect.equals(true, parseIntThrowsFormatException("+-5"));
481 Expect.equals(true, parseIntThrowsFormatException("-+5"));
482 Expect.equals(true, parseIntThrowsFormatException("--5"));
483 Expect.equals(true, parseIntThrowsFormatException("++5"));
484 Expect.equals(true, parseIntThrowsFormatException("+ 5"));
485 Expect.equals(true, parseIntThrowsFormatException("- 5"));
486 Expect.equals(true, parseIntThrowsFormatException(""));
487 Expect.equals(true, parseIntThrowsFormatException(" "));
488 Expect.equals(true, parseIntThrowsFormatException("+0x1234567890"));
489 Expect.equals(true, parseIntThrowsFormatException(" +0x1234567890 "));
490 Expect.equals(true, parseIntThrowsFormatException("+0x100"));
491 Expect.equals(true, parseIntThrowsFormatException(" +0x100 "));
492 }
493
494 static testMain() {
495 testConstants();
496 testSin();
497 testCos();
498 testTan();
499 testAsin();
500 testAcos();
501 testAtan();
502 testAtan2();
503 testSqrt();
504 testLog();
505 testExp();
506 testPow();
507 testParseInt();
508 }
509 }
510
511 main() {
512 MathTest.testMain();
513 MathLibraryTest.testMain();
514 }
OLDNEW
« no previous file with comments | « tests/corelib/math_parse_double_test.dart ('k') | tests/corelib/min_max_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698