| OLD | NEW |
| 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 library math_test; | 5 library math_test; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 void checkVeryClose(double a, double b) { | 9 void checkVeryClose(double a, double b) { |
| 10 // We find a ulp (unit in the last place) by shifting the original number | 10 // We find a ulp (unit in the last place) by shifting the original number |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // if `y` is zero (0.0 or -0.0), the result is always 1.0. | 59 // if `y` is zero (0.0 or -0.0), the result is always 1.0. |
| 60 Expect.identical(1.0, pow(d, 0.0), "$d"); | 60 Expect.identical(1.0, pow(d, 0.0), "$d"); |
| 61 Expect.identical(1.0, pow(d, -0.0), "$d"); | 61 Expect.identical(1.0, pow(d, -0.0), "$d"); |
| 62 } | 62 } |
| 63 for (var d in samples) { | 63 for (var d in samples) { |
| 64 // if `x` is 1.0, the result is always 1.0. | 64 // if `x` is 1.0, the result is always 1.0. |
| 65 Expect.identical(1.0, pow(1.0, d), "$d"); | 65 Expect.identical(1.0, pow(1.0, d), "$d"); |
| 66 } | 66 } |
| 67 for (var d in samples) { | 67 for (var d in samples) { |
| 68 // otherwise, if either `x` or `y` is NaN then the result is NaN. | 68 // otherwise, if either `x` or `y` is NaN then the result is NaN. |
| 69 if (d != 0.0) Expect.identical(NaN, pow(NaN, d), "$d"); | 69 if (d != 0.0) Expect.isTrue(pow(NaN, d).isNaN, "$d"); |
| 70 if (d != 1.0) Expect.identical(NaN, pow(d, NaN), "$d"); | 70 if (d != 1.0) Expect.isTrue(pow(d, NaN).isNaN, "$d"); |
| 71 } | 71 } |
| 72 | 72 |
| 73 for (var d in samples) { | 73 for (var d in samples) { |
| 74 // if `x` is a finite and strictly negative and `y` is a finite non-integer, | 74 // if `x` is a finite and strictly negative and `y` is a finite non-integer, |
| 75 // the result is NaN. | 75 // the result is NaN. |
| 76 if (d < 0 && !d.isInfinite) { | 76 if (d < 0 && !d.isInfinite) { |
| 77 Expect.identical(NaN, pow(d, 0.5), "$d"); | 77 Expect.isTrue(pow(d, 0.5).isNaN, "$d"); |
| 78 Expect.identical(NaN, pow(d, -0.5), "$d"); | 78 Expect.isTrue(pow(d, -0.5).isNaN, "$d"); |
| 79 Expect.identical(NaN, pow(d, 1.5), "$d"); | 79 Expect.isTrue(pow(d, 1.5).isNaN, "$d"); |
| 80 Expect.identical(NaN, pow(d, -1.5), "$d"); | 80 Expect.isTrue(pow(d, -1.5).isNaN, "$d"); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 for (var d in samples) { | 84 for (var d in samples) { |
| 85 if (d < 0) { | 85 if (d < 0) { |
| 86 // if `x` is Infinity and `y` is strictly negative, the result is 0.0. | 86 // if `x` is Infinity and `y` is strictly negative, the result is 0.0. |
| 87 Expect.identical(0.0, pow(Infinity, d), "$d"); | 87 Expect.identical(0.0, pow(Infinity, d), "$d"); |
| 88 } | 88 } |
| 89 if (d > 0) { | 89 if (d > 0) { |
| 90 // if `x` is Infinity and `y` is strictly positive, the result is Infinity
. | 90 // if `x` is Infinity and `y` is strictly positive, the result is Infinity
. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Underflow. | 149 // Underflow. |
| 150 Expect.identical(0.0, pow(10.0, -325.0)); | 150 Expect.identical(0.0, pow(10.0, -325.0)); |
| 151 | 151 |
| 152 // Conversion to double. | 152 // Conversion to double. |
| 153 | 153 |
| 154 // The second argument is an odd integer as int, but not when converted | 154 // The second argument is an odd integer as int, but not when converted |
| 155 // to double. | 155 // to double. |
| 156 Expect.identical(Infinity, pow(-0.0, -9223372036854775809)); | 156 Expect.identical(Infinity, pow(-0.0, -9223372036854775809)); |
| 157 } | 157 } |
| 158 | 158 |
| OLD | NEW |