| Index: tests/lib/math/min_max_test.dart
|
| diff --git a/tests/lib/math/min_max_test.dart b/tests/lib/math/min_max_test.dart
|
| index 46d05665e7af66f3d93457b953aab0099d9cbd92..a2ce160b9421f29fc8fe6debe2cc33b8e1732097 100644
|
| --- a/tests/lib/math/min_max_test.dart
|
| +++ b/tests/lib/math/min_max_test.dart
|
| @@ -11,10 +11,27 @@ import 'dart:math';
|
| var inf = double.INFINITY;
|
| var nan = double.NAN;
|
|
|
| +// A class that might work if [min] and [max] worked for non-numbers.
|
| +class Wrap implements Comparable {
|
| + final value;
|
| + Wrap(this.value);
|
| + int compare(Wrap other) => value.compare(other.value);
|
| + bool operator<(Wrap other) => compare(other) < 0;
|
| + bool operator<=(Wrap other) => compare(other) <= 0;
|
| + bool operator>(Wrap other) => compare(other) > 0;
|
| + bool operator>=(Wrap other) => compare(other) >= 0;
|
| + bool operator==(other) => other is Wrap && compare(other) == 0;
|
| + String toString() => 'Wrap($value)';
|
| +}
|
| +
|
| +var wrap1 = new Wrap(1);
|
| +var wrap2 = new Wrap(2);
|
| +
|
| testMin() {
|
| testMin1();
|
| testMin2();
|
| testMin3();
|
| + testMinChecks();
|
| }
|
|
|
| testMin1() {
|
| @@ -279,10 +296,18 @@ testMin3() {
|
| Expect.isFalse(min(inf, inf).isNegative);
|
| }
|
|
|
| +testMinChecks() {
|
| + // Min and max work only on numbers.
|
| + Expect.throws(() => min(wrap1, wrap2), (e) => e is ArgumentError);
|
| + Expect.throws(() => min(wrap1, 0), (e) => e is ArgumentError);
|
| + Expect.throws(() => min(0, wrap2), (e) => e is ArgumentError);
|
| +}
|
| +
|
| testMax() {
|
| testMax1();
|
| testMax2();
|
| testMax3();
|
| + testMaxChecks();
|
| }
|
|
|
| testMax1() {
|
| @@ -537,6 +562,13 @@ testMax3() {
|
| Expect.isTrue(max(-inf, -inf).isNegative);
|
| }
|
|
|
| +testMaxChecks() {
|
| + // Min and max work only on numbers.
|
| + Expect.throws(() => min(wrap1, wrap2), (e) => e is ArgumentError);
|
| + Expect.throws(() => min(wrap1, 0), (e) => e is ArgumentError);
|
| + Expect.throws(() => min(0, wrap2), (e) => e is ArgumentError);
|
| +}
|
| +
|
| main() {
|
| testMin();
|
| testMin();
|
|
|