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 class MathTest { | 9 class MathTest { |
10 static void testConstants() { | 10 static void testConstants() { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 static void testSqrt() { | 125 static void testSqrt() { |
126 checkVeryClose(2.0, sqrt(4.0)); | 126 checkVeryClose(2.0, sqrt(4.0)); |
127 checkVeryClose(SQRT2, sqrt(2.0)); | 127 checkVeryClose(SQRT2, sqrt(2.0)); |
128 checkVeryClose(SQRT1_2, sqrt(0.5)); | 128 checkVeryClose(SQRT1_2, sqrt(0.5)); |
129 checkVeryClose(1e50, sqrt(1e100)); | 129 checkVeryClose(1e50, sqrt(1e100)); |
130 checkVeryClose(1.1111111061110855443054405046358901279277111935183977e56, | 130 checkVeryClose(1.1111111061110855443054405046358901279277111935183977e56, |
131 sqrt(12345678901234e99)); | 131 sqrt(12345678901234e99)); |
132 } | 132 } |
133 | 133 |
134 static void testExp() { | 134 static void testExp() { |
135 final double EPSILON = 1e-15; | |
Lasse Reichstein Nielsen
2014/08/20 12:17:03
Unnecessary change.
srawlins
2014/08/25 05:43:54
Done.
| |
135 checkVeryClose(E, exp(1.0)); | 136 checkVeryClose(E, exp(1.0)); |
136 final EPSILON = 1e-15; | |
137 checkClose(10.0, exp(LN10), EPSILON); | 137 checkClose(10.0, exp(LN10), EPSILON); |
138 checkClose(2.0, exp(LN2), EPSILON); | 138 checkClose(2.0, exp(LN2), EPSILON); |
139 } | 139 } |
140 | 140 |
141 static void testLog() { | 141 static void testLog() { |
142 // Even though E is imprecise, it is good enough to get really close to 1. | 142 // Even though E is imprecise, it is good enough to get really close to 1. |
143 // We still provide an epsilon. | 143 // We still provide an epsilon. |
144 checkClose(1.0, log(E), 1e-16); | 144 checkClose(1.0, log(E), 1e-16); |
145 checkVeryClose(LN10, log(10.0)); | 145 checkVeryClose(LN10, log(10.0)); |
146 checkVeryClose(LN2, log(2.0)); | 146 checkVeryClose(LN2, log(2.0)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 testSqrt(); | 245 testSqrt(); |
246 testLog(); | 246 testLog(); |
247 testExp(); | 247 testExp(); |
248 testParseInt(); | 248 testParseInt(); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 main() { | 252 main() { |
253 MathTest.testMain(); | 253 MathTest.testMain(); |
254 } | 254 } |
OLD | NEW |