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

Side by Side Diff: tests/lib_strong/math/min_max_test.dart

Issue 2995343002: Migrated test block 216 to Dart 2.0. (Closed)
Patch Set: Migrated min_max_test to Dart 2.0 Created 3 years, 3 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
« no previous file with comments | « tests/lib_strong/lib_strong.status ('k') | tests/lib_strong/math/pi_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 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation
6
7 library min_max_test;
8
9 import "package:expect/expect.dart";
10 import 'dart:math';
11
12 var inf = double.INFINITY;
13 var nan = double.NAN;
14
15 // A class that might work if [min] and [max] worked for non-numbers.
16 class Wrap implements Comparable {
17 final value;
18 Wrap(this.value);
19 int compareTo(Wrap other) => value.compareTo(other.value);
20 bool operator <(Wrap other) => compareTo(other) < 0;
21 bool operator <=(Wrap other) => compareTo(other) <= 0;
22 bool operator >(Wrap other) => compareTo(other) > 0;
23 bool operator >=(Wrap other) => compareTo(other) >= 0;
24 bool operator ==(other) => other is Wrap && compareTo(other) == 0;
25 String toString() => 'Wrap($value)';
26 int get hashCode => value.hashCode;
27 }
28
29 var wrap1 = new Wrap(1);
30 var wrap2 = new Wrap(2);
31
32 testMin() {
33 testMin1();
34 testMin2();
35 testMin3();
36 testMinChecks();
37 }
38
39 testMin1() {
40 Expect.equals(0, min(0, 2));
41 Expect.equals(0, min(2, 0));
42
43 Expect.equals(-10, min(-10, -9));
44 Expect.equals(-10, min(-10, 9));
45 Expect.equals(-10, min(-10, 0));
46 Expect.equals(-10, min(-9, -10));
47 Expect.equals(-10, min(9, -10));
48 Expect.equals(-10, min(0, -10));
49
50 Expect.equals(0.5, min(0.5, 2.5));
51 Expect.equals(0.5, min(2.5, 0.5));
52
53 Expect.equals(-10.5, min(-10.5, -9.5));
54 Expect.equals(-10.5, min(-10.5, 9.5));
55 Expect.equals(-10.5, min(-10.5, 0.5));
56 Expect.equals(-10.5, min(-9.5, -10.5));
57 Expect.equals(-10.5, min(9.5, -10.5));
58 Expect.equals(-10.5, min(0.5, -10.5));
59 // Test matrix:
60 // NaN, -infinity, -499.0, -499, -0.0, 0.0, 0, 499.0, 499, +infinity.
61
62 Expect.isTrue(min(nan, nan).isNaN);
63 Expect.isTrue(min(nan, -inf).isNaN);
64 Expect.isTrue(min(nan, -499.0).isNaN);
65 Expect.isTrue(min(nan, -499).isNaN);
66 Expect.isTrue(min(nan, -0.0).isNaN);
67 Expect.isTrue(min(nan, 0.0).isNaN);
68 Expect.isTrue(min(nan, 499.0).isNaN);
69 Expect.isTrue(min(nan, 499).isNaN);
70 Expect.isTrue(min(nan, inf).isNaN);
71
72 Expect.equals(-inf, min(-inf, -inf));
73 Expect.equals(-inf, min(-inf, -499.0));
74 Expect.equals(-inf, min(-inf, -499));
75 Expect.equals(-inf, min(-inf, -0.0));
76 Expect.equals(-inf, min(-inf, 0.0));
77 Expect.equals(-inf, min(-inf, 0));
78 Expect.equals(-inf, min(-inf, 499));
79 Expect.equals(-inf, min(-inf, 499.0));
80 Expect.equals(-inf, min(-inf, inf));
81 Expect.isTrue(min(-inf, nan).isNaN);
82
83 Expect.equals(-inf, min(-499.0, -inf));
84 Expect.equals(-499.0, min(-499.0, -499.0));
85 Expect.equals(-499.0, min(-499.0, -499));
86 Expect.equals(-499.0, min(-499.0, -0.0));
87 Expect.equals(-499.0, min(-499.0, 0.0));
88 Expect.equals(-499.0, min(-499.0, 0));
89 Expect.equals(-499.0, min(-499.0, 499.0));
90 Expect.equals(-499.0, min(-499.0, 499));
91 Expect.equals(-499.0, min(-499.0, inf));
92 Expect.isTrue(min(-499.0, nan).isNaN);
93
94 Expect.isTrue(min(-499.0, -499.0) is double);
95 Expect.isTrue(min(-499.0, -499) is double);
96 Expect.isTrue(min(-499.0, -0.0) is double);
97 Expect.isTrue(min(-499.0, 0.0) is double);
98 Expect.isTrue(min(-499.0, 0) is double);
99 Expect.isTrue(min(-499.0, 499.0) is double);
100 Expect.isTrue(min(-499.0, 499) is double);
101 Expect.isTrue(min(-499.0, inf) is double);
102
103 Expect.equals(-inf, min(-499, -inf));
104 Expect.equals(-499, min(-499, -499.0));
105 Expect.equals(-499, min(-499, -499));
106 Expect.equals(-499, min(-499, -0.0));
107 Expect.equals(-499, min(-499, 0.0));
108 Expect.equals(-499, min(-499, 0));
109 Expect.equals(-499, min(-499, 499.0));
110 Expect.equals(-499, min(-499, 499));
111 Expect.equals(-499, min(-499, inf));
112 Expect.isTrue(min(-499, nan).isNaN);
113
114 Expect.isTrue(min(-499, -499.0) is int);
115 Expect.isTrue(min(-499, -499) is int);
116 Expect.isTrue(min(-499, -0.0) is int);
117 Expect.isTrue(min(-499, 0.0) is int);
118 Expect.isTrue(min(-499, 0) is int);
119 Expect.isTrue(min(-499, 499.0) is int);
120 Expect.isTrue(min(-499, 499) is int);
121 Expect.isTrue(min(-499, inf) is int);
122
123 Expect.equals(-inf, min(-0.0, -inf));
124 Expect.equals(-499.0, min(-0.0, -499.0));
125 Expect.equals(-499, min(-0.0, -499));
126 Expect.equals(-0.0, min(-0.0, -0.0));
127 Expect.equals(-0.0, min(-0.0, 0.0));
128 Expect.equals(-0.0, min(-0.0, 0));
129 Expect.equals(-0.0, min(-0.0, 499.0));
130 Expect.equals(-0.0, min(-0.0, 499));
131 Expect.equals(-0.0, min(-0.0, inf));
132 Expect.isTrue(min(-0.0, nan).isNaN);
133 }
134
135 testMin2() {
136 Expect.isTrue(min(-0.0, -499.0) is double);
137 Expect.isTrue(min(-0.0, -499) is int);
138 Expect.isTrue(min(-0.0, -0.0) is double);
139 Expect.isTrue(min(-0.0, 0.0) is double);
140 Expect.isTrue(min(-0.0, 0) is double);
141 Expect.isTrue(min(-0.0, 499.0) is double);
142 Expect.isTrue(min(-0.0, 499) is double);
143 Expect.isTrue(min(-0.0, inf) is double);
144
145 Expect.isTrue(min(-0.0, -499.0).isNegative);
146 Expect.isTrue(min(-0.0, -499).isNegative);
147 Expect.isTrue(min(-0.0, -0.0).isNegative);
148 Expect.isTrue(min(-0.0, 0.0).isNegative);
149 Expect.isTrue(min(-0.0, 0).isNegative);
150 Expect.isTrue(min(-0.0, 499.0).isNegative);
151 Expect.isTrue(min(-0.0, 499).isNegative);
152 Expect.isTrue(min(-0.0, inf).isNegative);
153
154 Expect.equals(-inf, min(0.0, -inf));
155 Expect.equals(-499.0, min(0.0, -499.0));
156 Expect.equals(-499, min(0.0, -499));
157 Expect.equals(-0.0, min(0.0, -0.0));
158 Expect.equals(0.0, min(0.0, 0.0));
159 Expect.equals(0.0, min(0.0, 0));
160 Expect.equals(0.0, min(0.0, 499.0));
161 Expect.equals(0.0, min(0.0, 499));
162 Expect.equals(0.0, min(0.0, inf));
163 Expect.isTrue(min(0.0, nan).isNaN);
164
165 Expect.isTrue(min(0.0, -499.0) is double);
166 Expect.isTrue(min(0.0, -499) is int);
167 Expect.isTrue(min(0.0, -0.0) is double);
168 Expect.isTrue(min(0.0, 0.0) is double);
169 Expect.isTrue(min(0.0, 0) is double);
170 Expect.isTrue(min(0.0, 499.0) is double);
171 Expect.isTrue(min(0.0, 499) is double);
172 Expect.isTrue(min(0.0, inf) is double);
173
174 Expect.isTrue(min(0.0, -499.0).isNegative);
175 Expect.isTrue(min(0.0, -499).isNegative);
176 Expect.isTrue(min(0.0, -0.0).isNegative);
177 Expect.isFalse(min(0.0, 0.0).isNegative);
178 Expect.isFalse(min(0.0, 0).isNegative);
179 Expect.isFalse(min(0.0, 499.0).isNegative);
180 Expect.isFalse(min(0.0, 499).isNegative);
181 Expect.isFalse(min(0.0, inf).isNegative);
182
183 Expect.equals(-inf, min(0, -inf));
184 Expect.equals(-499.0, min(0, -499.0));
185 Expect.equals(-499, min(0, -499));
186 Expect.equals(-0.0, min(0, -0.0));
187 Expect.equals(0, min(0, 0.0));
188 Expect.equals(0, min(0, 0));
189 Expect.equals(0, min(0, 499.0));
190 Expect.equals(0, min(0, 499));
191 Expect.equals(0, min(0, inf));
192 Expect.isTrue(min(0, nan).isNaN);
193
194 Expect.isTrue(min(0, -499.0) is double);
195 Expect.isTrue(min(0, -499) is int);
196 Expect.isTrue(min(0, -0.0) is double);
197 Expect.isTrue(min(0, 0.0) is int);
198 Expect.isTrue(min(0, 0) is int);
199 Expect.isTrue(min(0, 499.0) is int);
200 Expect.isTrue(min(0, 499) is int);
201 Expect.isTrue(min(0, inf) is int);
202 Expect.isTrue(min(0, -499.0).isNegative);
203 Expect.isTrue(min(0, -499).isNegative);
204 Expect.isTrue(min(0, -0.0).isNegative);
205 Expect.isFalse(min(0, 0.0).isNegative);
206 Expect.isFalse(min(0, 0).isNegative);
207 Expect.isFalse(min(0, 499.0).isNegative);
208 Expect.isFalse(min(0, 499).isNegative);
209 Expect.isFalse(min(0, inf).isNegative);
210 }
211
212 testMin3() {
213 Expect.equals(-inf, min(499.0, -inf));
214 Expect.equals(-499.0, min(499.0, -499.0));
215 Expect.equals(-499, min(499.0, -499));
216 Expect.equals(-0.0, min(499.0, -0.0));
217 Expect.equals(0.0, min(499.0, 0.0));
218 Expect.equals(0, min(499.0, 0));
219 Expect.equals(499.0, min(499.0, 499.0));
220 Expect.equals(499.0, min(499.0, 499));
221 Expect.equals(499.0, min(499.0, inf));
222 Expect.isTrue(min(499.0, nan).isNaN);
223
224 Expect.isTrue(min(499.0, -499.0) is double);
225 Expect.isTrue(min(499.0, -499) is int);
226 Expect.isTrue(min(499.0, -0.0) is double);
227 Expect.isTrue(min(499.0, 0.0) is double);
228 Expect.isTrue(min(499.0, 0) is int);
229 Expect.isTrue(min(499.0, 499) is double);
230 Expect.isTrue(min(499.0, 499.0) is double);
231 Expect.isTrue(min(499.0, inf) is double);
232
233 Expect.isTrue(min(499.0, -499.0).isNegative);
234 Expect.isTrue(min(499.0, -499).isNegative);
235 Expect.isTrue(min(499.0, -0.0).isNegative);
236 Expect.isFalse(min(499.0, 0.0).isNegative);
237 Expect.isFalse(min(499.0, 0).isNegative);
238 Expect.isFalse(min(499.0, 499).isNegative);
239 Expect.isFalse(min(499.0, 499.0).isNegative);
240 Expect.isFalse(min(499.0, inf).isNegative);
241
242 Expect.equals(-inf, min(499, -inf));
243 Expect.equals(-499.0, min(499, -499.0));
244 Expect.equals(-499, min(499, -499));
245 Expect.equals(-0.0, min(499, -0.0));
246 Expect.equals(0.0, min(499, 0.0));
247 Expect.equals(0, min(499, 0));
248 Expect.equals(499, min(499, 499.0));
249 Expect.equals(499, min(499, 499));
250 Expect.equals(499, min(499, inf));
251 Expect.isTrue(min(499, nan).isNaN);
252
253 Expect.isTrue(min(499, -499.0) is double);
254 Expect.isTrue(min(499, -499) is int);
255 Expect.isTrue(min(499, -0.0) is double);
256 Expect.isTrue(min(499, 0.0) is double);
257 Expect.isTrue(min(499, 0) is int);
258 Expect.isTrue(min(499, 499.0) is int);
259 Expect.isTrue(min(499, 499) is int);
260 Expect.isTrue(min(499, inf) is int);
261
262 Expect.isTrue(min(499, -499.0).isNegative);
263 Expect.isTrue(min(499, -499).isNegative);
264 Expect.isTrue(min(499, -0.0).isNegative);
265 Expect.isFalse(min(499, 0.0).isNegative);
266 Expect.isFalse(min(499, 0).isNegative);
267 Expect.isFalse(min(499, 499.0).isNegative);
268 Expect.isFalse(min(499, 499).isNegative);
269 Expect.isFalse(min(499, inf).isNegative);
270
271 Expect.equals(-inf, min(inf, -inf));
272 Expect.equals(-499.0, min(inf, -499.0));
273 Expect.equals(-499, min(inf, -499));
274 Expect.equals(-0.0, min(inf, -0.0));
275 Expect.equals(0.0, min(inf, 0.0));
276 Expect.equals(0, min(inf, 0));
277 Expect.equals(499.0, min(inf, 499.0));
278 Expect.equals(499, min(inf, 499));
279 Expect.equals(inf, min(inf, inf));
280 Expect.isTrue(min(inf, nan).isNaN);
281
282 Expect.isTrue(min(inf, -499.0) is double);
283 Expect.isTrue(min(inf, -499) is int);
284 Expect.isTrue(min(inf, -0.0) is double);
285 Expect.isTrue(min(inf, 0.0) is double);
286 Expect.isTrue(min(inf, 0) is int);
287 Expect.isTrue(min(inf, 499) is int);
288 Expect.isTrue(min(inf, 499.0) is double);
289 Expect.isTrue(min(inf, inf) is double);
290
291 Expect.isTrue(min(inf, -499.0).isNegative);
292 Expect.isTrue(min(inf, -499).isNegative);
293 Expect.isTrue(min(inf, -0.0).isNegative);
294 Expect.isFalse(min(inf, 0.0).isNegative);
295 Expect.isFalse(min(inf, 0).isNegative);
296 Expect.isFalse(min(inf, 499).isNegative);
297 Expect.isFalse(min(inf, 499.0).isNegative);
298 Expect.isFalse(min(inf, inf).isNegative);
299 }
300
301 testMinChecks() {
302 // Min and max work only on numbers.
303 // These throw a type assertion or ArgumentError.
304 Expect.throws(() => min(wrap1, wrap2));
305 Expect.throws(() => min(wrap1, 0));
306 Expect.throws(() => min(0, wrap2));
307 }
308
309 testMax() {
310 testMax1();
311 testMax2();
312 testMax3();
313 testMaxChecks();
314 }
315
316 testMax1() {
317 Expect.equals(2, max(0, 2));
318 Expect.equals(2, max(2, 0));
319
320 Expect.equals(-9, max(-10, -9));
321 Expect.equals(9, max(-10, 9));
322 Expect.equals(0, max(-10, 0));
323 Expect.equals(-9, max(-9, -10));
324 Expect.equals(9, max(9, -10));
325 Expect.equals(0, max(0, -10));
326
327 Expect.equals(2.5, max(0.5, 2.5));
328 Expect.equals(2.5, max(2.5, 0.5));
329
330 Expect.equals(-9.5, max(-10.5, -9.5));
331 Expect.equals(9.5, max(-10.5, 9.5));
332 Expect.equals(0.5, max(-10.5, 0.5));
333 Expect.equals(-9.5, max(-9.5, -10.5));
334 Expect.equals(9.5, max(9.5, -10.5));
335 Expect.equals(0.5, max(0.5, -10.5));
336
337 // Test matrix:
338 // NaN, infinity, 499.0, 499, 0.0, 0, -0.0, -499.0, -499, -infinity.
339
340 Expect.isTrue(max(nan, nan).isNaN);
341 Expect.isTrue(max(nan, -inf).isNaN);
342 Expect.isTrue(max(nan, -499.0).isNaN);
343 Expect.isTrue(max(nan, -499).isNaN);
344 Expect.isTrue(max(nan, -0.0).isNaN);
345 Expect.isTrue(max(nan, 0.0).isNaN);
346 Expect.isTrue(max(nan, 499.0).isNaN);
347 Expect.isTrue(max(nan, 499).isNaN);
348 Expect.isTrue(max(nan, inf).isNaN);
349
350 Expect.equals(inf, max(inf, inf));
351 Expect.equals(inf, max(inf, 499.0));
352 Expect.equals(inf, max(inf, 499));
353 Expect.equals(inf, max(inf, 0.0));
354 Expect.equals(inf, max(inf, 0));
355 Expect.equals(inf, max(inf, -0.0));
356 Expect.equals(inf, max(inf, -499));
357 Expect.equals(inf, max(inf, -499.0));
358 Expect.equals(inf, max(inf, -inf));
359 Expect.isTrue(max(inf, nan).isNaN);
360
361 Expect.equals(inf, max(499.0, inf));
362 Expect.equals(499.0, max(499.0, 499.0));
363 Expect.equals(499.0, max(499.0, 499));
364 Expect.equals(499.0, max(499.0, 0.0));
365 Expect.equals(499.0, max(499.0, 0));
366 Expect.equals(499.0, max(499.0, -0.0));
367 Expect.equals(499.0, max(499.0, -499));
368 Expect.equals(499.0, max(499.0, -499.0));
369 Expect.equals(499.0, max(499.0, -inf));
370 Expect.isTrue(max(499.0, nan).isNaN);
371
372 Expect.isTrue(max(499.0, 499.0) is double);
373 Expect.isTrue(max(499.0, 499) is double);
374 Expect.isTrue(max(499.0, 0.0) is double);
375 Expect.isTrue(max(499.0, 0) is double);
376 Expect.isTrue(max(499.0, -0.0) is double);
377 Expect.isTrue(max(499.0, -499) is double);
378 Expect.isTrue(max(499.0, -499.0) is double);
379 Expect.isTrue(max(499.0, -inf) is double);
380
381 Expect.equals(inf, max(499, inf));
382 Expect.equals(499, max(499, 499.0));
383 Expect.equals(499, max(499, 499));
384 Expect.equals(499, max(499, 0.0));
385 Expect.equals(499, max(499, 0));
386 Expect.equals(499, max(499, -0.0));
387 Expect.equals(499, max(499, -499));
388 Expect.equals(499, max(499, -499.0));
389 Expect.equals(499, max(499, -inf));
390 Expect.isTrue(max(499, nan).isNaN);
391
392 Expect.isTrue(max(499, 499.0) is int);
393 Expect.isTrue(max(499, 499) is int);
394 Expect.isTrue(max(499, 0.0) is int);
395 Expect.isTrue(max(499, 0) is int);
396 Expect.isTrue(max(499, -0.0) is int);
397 Expect.isTrue(max(499, -499) is int);
398 Expect.isTrue(max(499, -499.0) is int);
399 Expect.isTrue(max(499, -inf) is int);
400
401 Expect.equals(inf, max(0.0, inf));
402 Expect.equals(499.0, max(0.0, 499.0));
403 Expect.equals(499, max(0.0, 499));
404 Expect.equals(0.0, max(0.0, 0.0));
405 Expect.equals(0.0, max(0.0, 0));
406 Expect.equals(0.0, max(0.0, -0.0));
407 Expect.equals(0.0, max(0.0, -499));
408 Expect.equals(0.0, max(0.0, -499.0));
409 Expect.equals(0.0, max(0.0, -inf));
410 Expect.isTrue(max(0.0, nan).isNaN);
411
412 Expect.isTrue(max(0.0, 499.0) is double);
413 Expect.isTrue(max(0.0, 499) is int);
414 Expect.isTrue(max(0.0, 0.0) is double);
415 Expect.isTrue(max(0.0, 0) is double);
416 Expect.isTrue(max(0.0, -0.0) is double);
417 Expect.isTrue(max(0.0, -499) is double);
418 Expect.isTrue(max(0.0, -499.0) is double);
419 Expect.isTrue(max(0.0, -inf) is double);
420 }
421
422 testMax2() {
423 Expect.isFalse(max(0.0, 0.0).isNegative);
424 Expect.isFalse(max(0.0, 0).isNegative);
425 Expect.isFalse(max(0.0, -0.0).isNegative);
426 Expect.isFalse(max(0.0, -499).isNegative);
427 Expect.isFalse(max(0.0, -499.0).isNegative);
428 Expect.isFalse(max(0.0, -inf).isNegative);
429
430 Expect.equals(inf, max(0, inf));
431 Expect.equals(499.0, max(0, 499.0));
432 Expect.equals(499, max(0, 499));
433 Expect.equals(0, max(0, 0.0));
434 Expect.equals(0, max(0, 0));
435 Expect.equals(0, max(0, -0.0));
436 Expect.equals(0, max(0, -499));
437 Expect.equals(0, max(0, -499.0));
438 Expect.equals(0, max(0, -inf));
439 Expect.isTrue(max(0, nan).isNaN);
440
441 Expect.isTrue(max(0, 499.0) is double);
442 Expect.isTrue(max(0, 499) is int);
443 Expect.isTrue(max(0, 0.0) is int);
444 Expect.isTrue(max(0, 0) is int);
445 Expect.isTrue(max(0, -0.0) is int);
446 Expect.isTrue(max(0, -499) is int);
447 Expect.isTrue(max(0, -499.0) is int);
448 Expect.isTrue(max(0, -inf) is int);
449
450 Expect.isFalse(max(0, 0.0).isNegative);
451 Expect.isFalse(max(0, 0).isNegative);
452 Expect.isFalse(max(0, -0.0).isNegative);
453 Expect.isFalse(max(0, -499).isNegative);
454 Expect.isFalse(max(0, -499.0).isNegative);
455 Expect.isFalse(max(0, -inf).isNegative);
456
457 Expect.equals(inf, max(-0.0, inf));
458 Expect.equals(499.0, max(-0.0, 499.0));
459 Expect.equals(499, max(-0.0, 499));
460 Expect.equals(0.0, max(-0.0, 0.0));
461 Expect.equals(0.0, max(-0.0, 0));
462 Expect.equals(-0.0, max(-0.0, -0.0));
463 Expect.equals(-0.0, max(-0.0, -499));
464 Expect.equals(-0.0, max(-0.0, -499.0));
465 Expect.equals(-0.0, max(-0.0, -inf));
466 Expect.isTrue(max(-0.0, nan).isNaN);
467
468 Expect.isTrue(max(-0.0, 499.0) is double);
469 Expect.isTrue(max(-0.0, 499) is int);
470 Expect.isTrue(max(-0.0, 0.0) is double);
471 Expect.isTrue(max(-0.0, 0) is int);
472 Expect.isTrue(max(-0.0, -0.0) is double);
473 Expect.isTrue(max(-0.0, -499) is double);
474 Expect.isTrue(max(-0.0, -499.0) is double);
475 Expect.isTrue(max(-0.0, -inf) is double);
476 }
477
478 testMax3() {
479 Expect.isFalse(max(-0.0, 0.0).isNegative);
480 Expect.isFalse(max(-0.0, 0).isNegative);
481 Expect.isTrue(max(-0.0, -0.0).isNegative);
482 Expect.isTrue(max(-0.0, -499).isNegative);
483 Expect.isTrue(max(-0.0, -499.0).isNegative);
484 Expect.isTrue(max(-0.0, -inf).isNegative);
485
486 Expect.equals(inf, max(-499, inf));
487 Expect.equals(499.0, max(-499, 499.0));
488 Expect.equals(499, max(-499, 499));
489 Expect.equals(0.0, max(-499, 0.0));
490 Expect.equals(0.0, max(-499, 0));
491 Expect.equals(-0.0, max(-499, -0.0));
492 Expect.equals(-499, max(-499, -499));
493 Expect.equals(-499, max(-499, -499.0));
494 Expect.equals(-499, max(-499, -inf));
495 Expect.isTrue(max(-499, nan).isNaN);
496
497 Expect.isTrue(max(-499, 499.0) is double);
498 Expect.isTrue(max(-499, 499) is int);
499 Expect.isTrue(max(-499, 0.0) is double);
500 Expect.isTrue(max(-499, 0) is int);
501 Expect.isTrue(max(-499, -0.0) is double);
502 Expect.isTrue(max(-499, -499) is int);
503 Expect.isTrue(max(-499, -499.0) is int);
504 Expect.isTrue(max(-499, -inf) is int);
505
506 Expect.isFalse(max(-499, 0.0).isNegative);
507 Expect.isFalse(max(-499, 0).isNegative);
508 Expect.isTrue(max(-499, -0.0).isNegative);
509 Expect.isTrue(max(-499, -499).isNegative);
510 Expect.isTrue(max(-499, -499.0).isNegative);
511 Expect.isTrue(max(-499, -inf).isNegative);
512
513 Expect.equals(inf, max(-499.0, inf));
514 Expect.equals(499.0, max(-499.0, 499.0));
515 Expect.equals(499, max(-499.0, 499));
516 Expect.equals(0.0, max(-499.0, 0.0));
517 Expect.equals(0.0, max(-499.0, 0));
518 Expect.equals(-0.0, max(-499.0, -0.0));
519 Expect.equals(-499.0, max(-499.0, -499));
520 Expect.equals(-499.0, max(-499.0, -499.0));
521 Expect.equals(-499.0, max(-499.0, -inf));
522 Expect.isTrue(max(-499.0, nan).isNaN);
523
524 Expect.isTrue(max(-499.0, 499.0) is double);
525 Expect.isTrue(max(-499.0, 499) is int);
526 Expect.isTrue(max(-499.0, 0.0) is double);
527 Expect.isTrue(max(-499.0, 0) is int);
528 Expect.isTrue(max(-499.0, -0.0) is double);
529 Expect.isTrue(max(-499.0, -499) is double);
530 Expect.isTrue(max(-499.0, -499.0) is double);
531 Expect.isTrue(max(-499.0, -inf) is double);
532
533 Expect.isFalse(max(-499.0, 0.0).isNegative);
534 Expect.isFalse(max(-499.0, 0).isNegative);
535 Expect.isTrue(max(-499.0, -0.0).isNegative);
536 Expect.isTrue(max(-499.0, -499).isNegative);
537 Expect.isTrue(max(-499.0, -499.0).isNegative);
538 Expect.isTrue(max(-499.0, -inf).isNegative);
539
540 Expect.equals(inf, max(-inf, inf));
541 Expect.equals(499.0, max(-inf, 499.0));
542 Expect.equals(499, max(-inf, 499));
543 Expect.equals(0.0, max(-inf, 0.0));
544 Expect.equals(0.0, max(-inf, 0));
545 Expect.equals(-0.0, max(-inf, -0.0));
546 Expect.equals(-499, max(-inf, -499));
547 Expect.equals(-499.0, max(-inf, -499.0));
548 Expect.equals(-inf, max(-inf, -inf));
549 Expect.isTrue(max(-inf, nan).isNaN);
550
551 Expect.isTrue(max(-inf, 499.0) is double);
552 Expect.isTrue(max(-inf, 499) is int);
553 Expect.isTrue(max(-inf, 0.0) is double);
554 Expect.isTrue(max(-inf, 0) is int);
555 Expect.isTrue(max(-inf, -0.0) is double);
556 Expect.isTrue(max(-inf, -499) is int);
557 Expect.isTrue(max(-inf, -499.0) is double);
558 Expect.isTrue(max(-inf, -inf) is double);
559
560 Expect.isFalse(max(-inf, 0.0).isNegative);
561 Expect.isFalse(max(-inf, 0).isNegative);
562 Expect.isTrue(max(-inf, -0.0).isNegative);
563 Expect.isTrue(max(-inf, -499).isNegative);
564 Expect.isTrue(max(-inf, -499.0).isNegative);
565 Expect.isTrue(max(-inf, -inf).isNegative);
566 }
567
568 testMaxChecks() {
569 // Min and max work only on numbers.
570 // These throw a type assertion or ArgumentError.
571 Expect.throws(() => min(wrap1, wrap2));
572 Expect.throws(() => min(wrap1, 0));
573 Expect.throws(() => min(0, wrap2));
574 }
575
576 main() {
577 testMin();
578 testMin();
579 testMax();
580 testMax();
581 }
OLDNEW
« no previous file with comments | « tests/lib_strong/lib_strong.status ('k') | tests/lib_strong/math/pi_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698