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

Side by Side Diff: tests/corelib/min_max_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_test.dart ('k') | tests/corelib/stopwatch_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) 2012, 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 // Dart test for testing Math.min and Math.max.
5
6 testMin() {
7 Expect.equals(0, Math.min(0, 2));
8 Expect.equals(0, Math.min(2, 0));
9
10 Expect.equals(-10, Math.min(-10, -9));
11 Expect.equals(-10, Math.min(-10, 9));
12 Expect.equals(-10, Math.min(-10, 0));
13 Expect.equals(-10, Math.min(-9, -10));
14 Expect.equals(-10, Math.min(9, -10));
15 Expect.equals(-10, Math.min(0, -10));
16
17 Expect.equals(0.5, Math.min(0.5, 2.5));
18 Expect.equals(0.5, Math.min(2.5, 0.5));
19
20 Expect.equals(-10.5, Math.min(-10.5, -9.5));
21 Expect.equals(-10.5, Math.min(-10.5, 9.5));
22 Expect.equals(-10.5, Math.min(-10.5, 0.5));
23 Expect.equals(-10.5, Math.min(-9.5, -10.5));
24 Expect.equals(-10.5, Math.min(9.5, -10.5));
25 Expect.equals(-10.5, Math.min(0.5, -10.5));
26
27 // Test matrix:
28 // NaN, -infinity, -499.0, -499, -0.0, 0.0, 0, 499.0, 499, +infinity.
29 var inf = double.INFINITY;
30 var nan = double.NAN;
31
32 Expect.isTrue(Math.min(nan, nan).isNaN());
33 Expect.isTrue(Math.min(nan, -inf).isNaN());
34 Expect.isTrue(Math.min(nan, -499.0).isNaN());
35 Expect.isTrue(Math.min(nan, -499).isNaN());
36 Expect.isTrue(Math.min(nan, -0.0).isNaN());
37 Expect.isTrue(Math.min(nan, 0.0).isNaN());
38 Expect.isTrue(Math.min(nan, 499.0).isNaN());
39 Expect.isTrue(Math.min(nan, 499).isNaN());
40 Expect.isTrue(Math.min(nan, inf).isNaN());
41
42 Expect.equals(-inf, Math.min(-inf, -inf));
43 Expect.equals(-inf, Math.min(-inf, -499.0));
44 Expect.equals(-inf, Math.min(-inf, -499));
45 Expect.equals(-inf, Math.min(-inf, -0.0));
46 Expect.equals(-inf, Math.min(-inf, 0.0));
47 Expect.equals(-inf, Math.min(-inf, 0));
48 Expect.equals(-inf, Math.min(-inf, 499));
49 Expect.equals(-inf, Math.min(-inf, 499.0));
50 Expect.equals(-inf, Math.min(-inf, inf));
51 Expect.isTrue(Math.min(-inf, nan).isNaN());
52
53 Expect.equals(-inf, Math.min(-499.0, -inf));
54 Expect.equals(-499.0, Math.min(-499.0, -499.0));
55 Expect.equals(-499.0, Math.min(-499.0, -499));
56 Expect.equals(-499.0, Math.min(-499.0, -0.0));
57 Expect.equals(-499.0, Math.min(-499.0, 0.0));
58 Expect.equals(-499.0, Math.min(-499.0, 0));
59 Expect.equals(-499.0, Math.min(-499.0, 499.0));
60 Expect.equals(-499.0, Math.min(-499.0, 499));
61 Expect.equals(-499.0, Math.min(-499.0, inf));
62 Expect.isTrue(Math.min(-499.0, nan).isNaN());
63
64 Expect.isTrue(Math.min(-499.0, -499.0) is double);
65 Expect.isTrue(Math.min(-499.0, -499) is double);
66 Expect.isTrue(Math.min(-499.0, -0.0) is double);
67 Expect.isTrue(Math.min(-499.0, 0.0) is double);
68 Expect.isTrue(Math.min(-499.0, 0) is double);
69 Expect.isTrue(Math.min(-499.0, 499.0) is double);
70 Expect.isTrue(Math.min(-499.0, 499) is double);
71 Expect.isTrue(Math.min(-499.0, inf) is double);
72
73 Expect.equals(-inf, Math.min(-499, -inf));
74 Expect.equals(-499, Math.min(-499, -499.0));
75 Expect.equals(-499, Math.min(-499, -499));
76 Expect.equals(-499, Math.min(-499, -0.0));
77 Expect.equals(-499, Math.min(-499, 0.0));
78 Expect.equals(-499, Math.min(-499, 0));
79 Expect.equals(-499, Math.min(-499, 499.0));
80 Expect.equals(-499, Math.min(-499, 499));
81 Expect.equals(-499, Math.min(-499, inf));
82 Expect.isTrue(Math.min(-499, nan).isNaN());
83
84 Expect.isTrue(Math.min(-499, -499.0) is int);
85 Expect.isTrue(Math.min(-499, -499) is int);
86 Expect.isTrue(Math.min(-499, -0.0) is int);
87 Expect.isTrue(Math.min(-499, 0.0) is int);
88 Expect.isTrue(Math.min(-499, 0) is int);
89 Expect.isTrue(Math.min(-499, 499.0) is int);
90 Expect.isTrue(Math.min(-499, 499) is int);
91 Expect.isTrue(Math.min(-499, inf) is int);
92
93 Expect.equals(-inf, Math.min(-0.0, -inf));
94 Expect.equals(-499.0, Math.min(-0.0, -499.0));
95 Expect.equals(-499, Math.min(-0.0, -499));
96 Expect.equals(-0.0, Math.min(-0.0, -0.0));
97 Expect.equals(-0.0, Math.min(-0.0, 0.0));
98 Expect.equals(-0.0, Math.min(-0.0, 0));
99 Expect.equals(-0.0, Math.min(-0.0, 499.0));
100 Expect.equals(-0.0, Math.min(-0.0, 499));
101 Expect.equals(-0.0, Math.min(-0.0, inf));
102 Expect.isTrue(Math.min(-0.0, nan).isNaN());
103
104 Expect.isTrue(Math.min(-0.0, -499.0) is double);
105 Expect.isTrue(Math.min(-0.0, -499) is int);
106 Expect.isTrue(Math.min(-0.0, -0.0) is double);
107 Expect.isTrue(Math.min(-0.0, 0.0) is double);
108 Expect.isTrue(Math.min(-0.0, 0) is double);
109 Expect.isTrue(Math.min(-0.0, 499.0) is double);
110 Expect.isTrue(Math.min(-0.0, 499) is double);
111 Expect.isTrue(Math.min(-0.0, inf) is double);
112
113 Expect.isTrue(Math.min(-0.0, -499.0).isNegative());
114 Expect.isTrue(Math.min(-0.0, -499).isNegative());
115 Expect.isTrue(Math.min(-0.0, -0.0).isNegative());
116 Expect.isTrue(Math.min(-0.0, 0.0).isNegative());
117 Expect.isTrue(Math.min(-0.0, 0).isNegative());
118 Expect.isTrue(Math.min(-0.0, 499.0).isNegative());
119 Expect.isTrue(Math.min(-0.0, 499).isNegative());
120 Expect.isTrue(Math.min(-0.0, inf).isNegative());
121
122 Expect.equals(-inf, Math.min(0.0, -inf));
123 Expect.equals(-499.0, Math.min(0.0, -499.0));
124 Expect.equals(-499, Math.min(0.0, -499));
125 Expect.equals(-0.0, Math.min(0.0, -0.0));
126 Expect.equals(0.0, Math.min(0.0, 0.0));
127 Expect.equals(0.0, Math.min(0.0, 0));
128 Expect.equals(0.0, Math.min(0.0, 499.0));
129 Expect.equals(0.0, Math.min(0.0, 499));
130 Expect.equals(0.0, Math.min(0.0, inf));
131 Expect.isTrue(Math.min(0.0, nan).isNaN());
132
133 Expect.isTrue(Math.min(0.0, -499.0) is double);
134 Expect.isTrue(Math.min(0.0, -499) is int);
135 Expect.isTrue(Math.min(0.0, -0.0) is double);
136 Expect.isTrue(Math.min(0.0, 0.0) is double);
137 Expect.isTrue(Math.min(0.0, 0) is double);
138 Expect.isTrue(Math.min(0.0, 499.0) is double);
139 Expect.isTrue(Math.min(0.0, 499) is double);
140 Expect.isTrue(Math.min(0.0, inf) is double);
141
142 Expect.isTrue(Math.min(0.0, -499.0).isNegative());
143 Expect.isTrue(Math.min(0.0, -499).isNegative());
144 Expect.isTrue(Math.min(0.0, -0.0).isNegative());
145 Expect.isFalse(Math.min(0.0, 0.0).isNegative());
146 Expect.isFalse(Math.min(0.0, 0).isNegative());
147 Expect.isFalse(Math.min(0.0, 499.0).isNegative());
148 Expect.isFalse(Math.min(0.0, 499).isNegative());
149 Expect.isFalse(Math.min(0.0, inf).isNegative());
150
151 Expect.equals(-inf, Math.min(0, -inf));
152 Expect.equals(-499.0, Math.min(0, -499.0));
153 Expect.equals(-499, Math.min(0, -499));
154 Expect.equals(-0.0, Math.min(0, -0.0));
155 Expect.equals(0, Math.min(0, 0.0));
156 Expect.equals(0, Math.min(0, 0));
157 Expect.equals(0, Math.min(0, 499.0));
158 Expect.equals(0, Math.min(0, 499));
159 Expect.equals(0, Math.min(0, inf));
160 Expect.isTrue(Math.min(0, nan).isNaN());
161
162 Expect.isTrue(Math.min(0, -499.0) is double);
163 Expect.isTrue(Math.min(0, -499) is int);
164 Expect.isTrue(Math.min(0, -0.0) is double);
165 Expect.isTrue(Math.min(0, 0.0) is int);
166 Expect.isTrue(Math.min(0, 0) is int);
167 Expect.isTrue(Math.min(0, 499.0) is int);
168 Expect.isTrue(Math.min(0, 499) is int);
169 Expect.isTrue(Math.min(0, inf) is int);
170
171 Expect.isTrue(Math.min(0, -499.0).isNegative());
172 Expect.isTrue(Math.min(0, -499).isNegative());
173 Expect.isTrue(Math.min(0, -0.0).isNegative());
174 Expect.isFalse(Math.min(0, 0.0).isNegative());
175 Expect.isFalse(Math.min(0, 0).isNegative());
176 Expect.isFalse(Math.min(0, 499.0).isNegative());
177 Expect.isFalse(Math.min(0, 499).isNegative());
178 Expect.isFalse(Math.min(0, inf).isNegative());
179
180 Expect.equals(-inf, Math.min(499.0, -inf));
181 Expect.equals(-499.0, Math.min(499.0, -499.0));
182 Expect.equals(-499, Math.min(499.0, -499));
183 Expect.equals(-0.0, Math.min(499.0, -0.0));
184 Expect.equals(0.0, Math.min(499.0, 0.0));
185 Expect.equals(0, Math.min(499.0, 0));
186 Expect.equals(499.0, Math.min(499.0, 499.0));
187 Expect.equals(499.0, Math.min(499.0, 499));
188 Expect.equals(499.0, Math.min(499.0, inf));
189 Expect.isTrue(Math.min(499.0, nan).isNaN());
190
191 Expect.isTrue(Math.min(499.0, -499.0) is double);
192 Expect.isTrue(Math.min(499.0, -499) is int);
193 Expect.isTrue(Math.min(499.0, -0.0) is double);
194 Expect.isTrue(Math.min(499.0, 0.0) is double);
195 Expect.isTrue(Math.min(499.0, 0) is int);
196 Expect.isTrue(Math.min(499.0, 499) is double);
197 Expect.isTrue(Math.min(499.0, 499.0) is double);
198 Expect.isTrue(Math.min(499.0, inf) is double);
199
200 Expect.isTrue(Math.min(499.0, -499.0).isNegative());
201 Expect.isTrue(Math.min(499.0, -499).isNegative());
202 Expect.isTrue(Math.min(499.0, -0.0).isNegative());
203 Expect.isFalse(Math.min(499.0, 0.0).isNegative());
204 Expect.isFalse(Math.min(499.0, 0).isNegative());
205 Expect.isFalse(Math.min(499.0, 499).isNegative());
206 Expect.isFalse(Math.min(499.0, 499.0).isNegative());
207 Expect.isFalse(Math.min(499.0, inf).isNegative());
208
209 Expect.equals(-inf, Math.min(499, -inf));
210 Expect.equals(-499.0, Math.min(499, -499.0));
211 Expect.equals(-499, Math.min(499, -499));
212 Expect.equals(-0.0, Math.min(499, -0.0));
213 Expect.equals(0.0, Math.min(499, 0.0));
214 Expect.equals(0, Math.min(499, 0));
215 Expect.equals(499, Math.min(499, 499.0));
216 Expect.equals(499, Math.min(499, 499));
217 Expect.equals(499, Math.min(499, inf));
218 Expect.isTrue(Math.min(499, nan).isNaN());
219
220 Expect.isTrue(Math.min(499, -499.0) is double);
221 Expect.isTrue(Math.min(499, -499) is int);
222 Expect.isTrue(Math.min(499, -0.0) is double);
223 Expect.isTrue(Math.min(499, 0.0) is double);
224 Expect.isTrue(Math.min(499, 0) is int);
225 Expect.isTrue(Math.min(499, 499.0) is int);
226 Expect.isTrue(Math.min(499, 499) is int);
227 Expect.isTrue(Math.min(499, inf) is int);
228
229 Expect.isTrue(Math.min(499, -499.0).isNegative());
230 Expect.isTrue(Math.min(499, -499).isNegative());
231 Expect.isTrue(Math.min(499, -0.0).isNegative());
232 Expect.isFalse(Math.min(499, 0.0).isNegative());
233 Expect.isFalse(Math.min(499, 0).isNegative());
234 Expect.isFalse(Math.min(499, 499.0).isNegative());
235 Expect.isFalse(Math.min(499, 499).isNegative());
236 Expect.isFalse(Math.min(499, inf).isNegative());
237
238 Expect.equals(-inf, Math.min(inf, -inf));
239 Expect.equals(-499.0, Math.min(inf, -499.0));
240 Expect.equals(-499, Math.min(inf, -499));
241 Expect.equals(-0.0, Math.min(inf, -0.0));
242 Expect.equals(0.0, Math.min(inf, 0.0));
243 Expect.equals(0, Math.min(inf, 0));
244 Expect.equals(499.0, Math.min(inf, 499.0));
245 Expect.equals(499, Math.min(inf, 499));
246 Expect.equals(inf, Math.min(inf, inf));
247 Expect.isTrue(Math.min(inf, nan).isNaN());
248
249 Expect.isTrue(Math.min(inf, -499.0) is double);
250 Expect.isTrue(Math.min(inf, -499) is int);
251 Expect.isTrue(Math.min(inf, -0.0) is double);
252 Expect.isTrue(Math.min(inf, 0.0) is double);
253 Expect.isTrue(Math.min(inf, 0) is int);
254 Expect.isTrue(Math.min(inf, 499) is int);
255 Expect.isTrue(Math.min(inf, 499.0) is double);
256 Expect.isTrue(Math.min(inf, inf) is double);
257
258 Expect.isTrue(Math.min(inf, -499.0).isNegative());
259 Expect.isTrue(Math.min(inf, -499).isNegative());
260 Expect.isTrue(Math.min(inf, -0.0).isNegative());
261 Expect.isFalse(Math.min(inf, 0.0).isNegative());
262 Expect.isFalse(Math.min(inf, 0).isNegative());
263 Expect.isFalse(Math.min(inf, 499).isNegative());
264 Expect.isFalse(Math.min(inf, 499.0).isNegative());
265 Expect.isFalse(Math.min(inf, inf).isNegative());
266 }
267
268 testMax() {
269 Expect.equals(2, Math.max(0, 2));
270 Expect.equals(2, Math.max(2, 0));
271
272 Expect.equals(-9, Math.max(-10, -9));
273 Expect.equals(9, Math.max(-10, 9));
274 Expect.equals(0, Math.max(-10, 0));
275 Expect.equals(-9, Math.max(-9, -10));
276 Expect.equals(9, Math.max(9, -10));
277 Expect.equals(0, Math.max(0, -10));
278
279 Expect.equals(2.5, Math.max(0.5, 2.5));
280 Expect.equals(2.5, Math.max(2.5, 0.5));
281
282 Expect.equals(-9.5, Math.max(-10.5, -9.5));
283 Expect.equals(9.5, Math.max(-10.5, 9.5));
284 Expect.equals(0.5, Math.max(-10.5, 0.5));
285 Expect.equals(-9.5, Math.max(-9.5, -10.5));
286 Expect.equals(9.5, Math.max(9.5, -10.5));
287 Expect.equals(0.5, Math.max(0.5, -10.5));
288
289 // Test matrix:
290 // NaN, infinity, 499.0, 499, 0.0, 0, -0.0, -499.0, -499, -infinity.
291 var inf = double.INFINITY;
292 var nan = double.NAN;
293
294 Expect.isTrue(Math.max(nan, nan).isNaN());
295 Expect.isTrue(Math.max(nan, -inf).isNaN());
296 Expect.isTrue(Math.max(nan, -499.0).isNaN());
297 Expect.isTrue(Math.max(nan, -499).isNaN());
298 Expect.isTrue(Math.max(nan, -0.0).isNaN());
299 Expect.isTrue(Math.max(nan, 0.0).isNaN());
300 Expect.isTrue(Math.max(nan, 499.0).isNaN());
301 Expect.isTrue(Math.max(nan, 499).isNaN());
302 Expect.isTrue(Math.max(nan, inf).isNaN());
303
304 Expect.equals(inf, Math.max(inf, inf));
305 Expect.equals(inf, Math.max(inf, 499.0));
306 Expect.equals(inf, Math.max(inf, 499));
307 Expect.equals(inf, Math.max(inf, 0.0));
308 Expect.equals(inf, Math.max(inf, 0));
309 Expect.equals(inf, Math.max(inf, -0.0));
310 Expect.equals(inf, Math.max(inf, -499));
311 Expect.equals(inf, Math.max(inf, -499.0));
312 Expect.equals(inf, Math.max(inf, -inf));
313 Expect.isTrue(Math.max(inf, nan).isNaN());
314
315 Expect.equals(inf, Math.max(499.0, inf));
316 Expect.equals(499.0, Math.max(499.0, 499.0));
317 Expect.equals(499.0, Math.max(499.0, 499));
318 Expect.equals(499.0, Math.max(499.0, 0.0));
319 Expect.equals(499.0, Math.max(499.0, 0));
320 Expect.equals(499.0, Math.max(499.0, -0.0));
321 Expect.equals(499.0, Math.max(499.0, -499));
322 Expect.equals(499.0, Math.max(499.0, -499.0));
323 Expect.equals(499.0, Math.max(499.0, -inf));
324 Expect.isTrue(Math.max(499.0, nan).isNaN());
325
326 Expect.isTrue(Math.max(499.0, 499.0) is double);
327 Expect.isTrue(Math.max(499.0, 499) is double);
328 Expect.isTrue(Math.max(499.0, 0.0) is double);
329 Expect.isTrue(Math.max(499.0, 0) is double);
330 Expect.isTrue(Math.max(499.0, -0.0) is double);
331 Expect.isTrue(Math.max(499.0, -499) is double);
332 Expect.isTrue(Math.max(499.0, -499.0) is double);
333 Expect.isTrue(Math.max(499.0, -inf) is double);
334
335 Expect.equals(inf, Math.max(499, inf));
336 Expect.equals(499, Math.max(499, 499.0));
337 Expect.equals(499, Math.max(499, 499));
338 Expect.equals(499, Math.max(499, 0.0));
339 Expect.equals(499, Math.max(499, 0));
340 Expect.equals(499, Math.max(499, -0.0));
341 Expect.equals(499, Math.max(499, -499));
342 Expect.equals(499, Math.max(499, -499.0));
343 Expect.equals(499, Math.max(499, -inf));
344 Expect.isTrue(Math.max(499, nan).isNaN());
345
346 Expect.isTrue(Math.max(499, 499.0) is int);
347 Expect.isTrue(Math.max(499, 499) is int);
348 Expect.isTrue(Math.max(499, 0.0) is int);
349 Expect.isTrue(Math.max(499, 0) is int);
350 Expect.isTrue(Math.max(499, -0.0) is int);
351 Expect.isTrue(Math.max(499, -499) is int);
352 Expect.isTrue(Math.max(499, -499.0) is int);
353 Expect.isTrue(Math.max(499, -inf) is int);
354
355 Expect.equals(inf, Math.max(0.0, inf));
356 Expect.equals(499.0, Math.max(0.0, 499.0));
357 Expect.equals(499, Math.max(0.0, 499));
358 Expect.equals(0.0, Math.max(0.0, 0.0));
359 Expect.equals(0.0, Math.max(0.0, 0));
360 Expect.equals(0.0, Math.max(0.0, -0.0));
361 Expect.equals(0.0, Math.max(0.0, -499));
362 Expect.equals(0.0, Math.max(0.0, -499.0));
363 Expect.equals(0.0, Math.max(0.0, -inf));
364 Expect.isTrue(Math.max(0.0, nan).isNaN());
365
366 Expect.isTrue(Math.max(0.0, 499.0) is double);
367 Expect.isTrue(Math.max(0.0, 499) is int);
368 Expect.isTrue(Math.max(0.0, 0.0) is double);
369 Expect.isTrue(Math.max(0.0, 0) is double);
370 Expect.isTrue(Math.max(0.0, -0.0) is double);
371 Expect.isTrue(Math.max(0.0, -499) is double);
372 Expect.isTrue(Math.max(0.0, -499.0) is double);
373 Expect.isTrue(Math.max(0.0, -inf) is double);
374
375 Expect.isFalse(Math.max(0.0, 0.0).isNegative());
376 Expect.isFalse(Math.max(0.0, 0).isNegative());
377 Expect.isFalse(Math.max(0.0, -0.0).isNegative());
378 Expect.isFalse(Math.max(0.0, -499).isNegative());
379 Expect.isFalse(Math.max(0.0, -499.0).isNegative());
380 Expect.isFalse(Math.max(0.0, -inf).isNegative());
381
382 Expect.equals(inf, Math.max(0, inf));
383 Expect.equals(499.0, Math.max(0, 499.0));
384 Expect.equals(499, Math.max(0, 499));
385 Expect.equals(0, Math.max(0, 0.0));
386 Expect.equals(0, Math.max(0, 0));
387 Expect.equals(0, Math.max(0, -0.0));
388 Expect.equals(0, Math.max(0, -499));
389 Expect.equals(0, Math.max(0, -499.0));
390 Expect.equals(0, Math.max(0, -inf));
391 Expect.isTrue(Math.max(0, nan).isNaN());
392
393 Expect.isTrue(Math.max(0, 499.0) is double);
394 Expect.isTrue(Math.max(0, 499) is int);
395 Expect.isTrue(Math.max(0, 0.0) is int);
396 Expect.isTrue(Math.max(0, 0) is int);
397 Expect.isTrue(Math.max(0, -0.0) is int);
398 Expect.isTrue(Math.max(0, -499) is int);
399 Expect.isTrue(Math.max(0, -499.0) is int);
400 Expect.isTrue(Math.max(0, -inf) is int);
401
402 Expect.isFalse(Math.max(0, 0.0).isNegative());
403 Expect.isFalse(Math.max(0, 0).isNegative());
404 Expect.isFalse(Math.max(0, -0.0).isNegative());
405 Expect.isFalse(Math.max(0, -499).isNegative());
406 Expect.isFalse(Math.max(0, -499.0).isNegative());
407 Expect.isFalse(Math.max(0, -inf).isNegative());
408
409 Expect.equals(inf, Math.max(-0.0, inf));
410 Expect.equals(499.0, Math.max(-0.0, 499.0));
411 Expect.equals(499, Math.max(-0.0, 499));
412 Expect.equals(0.0, Math.max(-0.0, 0.0));
413 Expect.equals(0.0, Math.max(-0.0, 0));
414 Expect.equals(-0.0, Math.max(-0.0, -0.0));
415 Expect.equals(-0.0, Math.max(-0.0, -499));
416 Expect.equals(-0.0, Math.max(-0.0, -499.0));
417 Expect.equals(-0.0, Math.max(-0.0, -inf));
418 Expect.isTrue(Math.max(-0.0, nan).isNaN());
419
420 Expect.isTrue(Math.max(-0.0, 499.0) is double);
421 Expect.isTrue(Math.max(-0.0, 499) is int);
422 Expect.isTrue(Math.max(-0.0, 0.0) is double);
423 Expect.isTrue(Math.max(-0.0, 0) is int);
424 Expect.isTrue(Math.max(-0.0, -0.0) is double);
425 Expect.isTrue(Math.max(-0.0, -499) is double);
426 Expect.isTrue(Math.max(-0.0, -499.0) is double);
427 Expect.isTrue(Math.max(-0.0, -inf) is double);
428
429 Expect.isFalse(Math.max(-0.0, 0.0).isNegative());
430 Expect.isFalse(Math.max(-0.0, 0).isNegative());
431 Expect.isTrue(Math.max(-0.0, -0.0).isNegative());
432 Expect.isTrue(Math.max(-0.0, -499).isNegative());
433 Expect.isTrue(Math.max(-0.0, -499.0).isNegative());
434 Expect.isTrue(Math.max(-0.0, -inf).isNegative());
435
436 Expect.equals(inf, Math.max(-499, inf));
437 Expect.equals(499.0, Math.max(-499, 499.0));
438 Expect.equals(499, Math.max(-499, 499));
439 Expect.equals(0.0, Math.max(-499, 0.0));
440 Expect.equals(0.0, Math.max(-499, 0));
441 Expect.equals(-0.0, Math.max(-499, -0.0));
442 Expect.equals(-499, Math.max(-499, -499));
443 Expect.equals(-499, Math.max(-499, -499.0));
444 Expect.equals(-499, Math.max(-499, -inf));
445 Expect.isTrue(Math.max(-499, nan).isNaN());
446
447 Expect.isTrue(Math.max(-499, 499.0) is double);
448 Expect.isTrue(Math.max(-499, 499) is int);
449 Expect.isTrue(Math.max(-499, 0.0) is double);
450 Expect.isTrue(Math.max(-499, 0) is int);
451 Expect.isTrue(Math.max(-499, -0.0) is double);
452 Expect.isTrue(Math.max(-499, -499) is int);
453 Expect.isTrue(Math.max(-499, -499.0) is int);
454 Expect.isTrue(Math.max(-499, -inf) is int);
455
456 Expect.isFalse(Math.max(-499, 0.0).isNegative());
457 Expect.isFalse(Math.max(-499, 0).isNegative());
458 Expect.isTrue(Math.max(-499, -0.0).isNegative());
459 Expect.isTrue(Math.max(-499, -499).isNegative());
460 Expect.isTrue(Math.max(-499, -499.0).isNegative());
461 Expect.isTrue(Math.max(-499, -inf).isNegative());
462
463 Expect.equals(inf, Math.max(-499.0, inf));
464 Expect.equals(499.0, Math.max(-499.0, 499.0));
465 Expect.equals(499, Math.max(-499.0, 499));
466 Expect.equals(0.0, Math.max(-499.0, 0.0));
467 Expect.equals(0.0, Math.max(-499.0, 0));
468 Expect.equals(-0.0, Math.max(-499.0, -0.0));
469 Expect.equals(-499.0, Math.max(-499.0, -499));
470 Expect.equals(-499.0, Math.max(-499.0, -499.0));
471 Expect.equals(-499.0, Math.max(-499.0, -inf));
472 Expect.isTrue(Math.max(-499.0, nan).isNaN());
473
474 Expect.isTrue(Math.max(-499.0, 499.0) is double);
475 Expect.isTrue(Math.max(-499.0, 499) is int);
476 Expect.isTrue(Math.max(-499.0, 0.0) is double);
477 Expect.isTrue(Math.max(-499.0, 0) is int);
478 Expect.isTrue(Math.max(-499.0, -0.0) is double);
479 Expect.isTrue(Math.max(-499.0, -499) is double);
480 Expect.isTrue(Math.max(-499.0, -499.0) is double);
481 Expect.isTrue(Math.max(-499.0, -inf) is double);
482
483 Expect.isFalse(Math.max(-499.0, 0.0).isNegative());
484 Expect.isFalse(Math.max(-499.0, 0).isNegative());
485 Expect.isTrue(Math.max(-499.0, -0.0).isNegative());
486 Expect.isTrue(Math.max(-499.0, -499).isNegative());
487 Expect.isTrue(Math.max(-499.0, -499.0).isNegative());
488 Expect.isTrue(Math.max(-499.0, -inf).isNegative());
489
490 Expect.equals(inf, Math.max(-inf, inf));
491 Expect.equals(499.0, Math.max(-inf, 499.0));
492 Expect.equals(499, Math.max(-inf, 499));
493 Expect.equals(0.0, Math.max(-inf, 0.0));
494 Expect.equals(0.0, Math.max(-inf, 0));
495 Expect.equals(-0.0, Math.max(-inf, -0.0));
496 Expect.equals(-499, Math.max(-inf, -499));
497 Expect.equals(-499.0, Math.max(-inf, -499.0));
498 Expect.equals(-inf, Math.max(-inf, -inf));
499 Expect.isTrue(Math.max(-inf, nan).isNaN());
500
501 Expect.isTrue(Math.max(-inf, 499.0) is double);
502 Expect.isTrue(Math.max(-inf, 499) is int);
503 Expect.isTrue(Math.max(-inf, 0.0) is double);
504 Expect.isTrue(Math.max(-inf, 0) is int);
505 Expect.isTrue(Math.max(-inf, -0.0) is double);
506 Expect.isTrue(Math.max(-inf, -499) is int);
507 Expect.isTrue(Math.max(-inf, -499.0) is double);
508 Expect.isTrue(Math.max(-inf, -inf) is double);
509
510 Expect.isFalse(Math.max(-inf, 0.0).isNegative());
511 Expect.isFalse(Math.max(-inf, 0).isNegative());
512 Expect.isTrue(Math.max(-inf, -0.0).isNegative());
513 Expect.isTrue(Math.max(-inf, -499).isNegative());
514 Expect.isTrue(Math.max(-inf, -499.0).isNegative());
515 Expect.isTrue(Math.max(-inf, -inf).isNegative());
516 }
517
518 main() {
519 testMin();
520 testMax();
521 }
OLDNEW
« no previous file with comments | « tests/corelib/math_test.dart ('k') | tests/corelib/stopwatch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698