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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)); |
147 } | 147 } |
148 | 148 |
149 static void testPow() { | |
150 checkVeryClose(16.0, pow(4.0, 2.0)); | |
151 checkVeryClose(SQRT2, pow(2.0, 0.5)); | |
152 checkVeryClose(SQRT1_2, pow(0.5, 0.5)); | |
153 } | |
154 | |
155 static bool parseIntThrowsFormatException(str) { | 149 static bool parseIntThrowsFormatException(str) { |
156 try { | 150 try { |
157 int.parse(str); | 151 int.parse(str); |
158 return false; | 152 return false; |
159 } on FormatException catch (e) { | 153 } on FormatException catch (e) { |
160 return true; | 154 return true; |
161 } | 155 } |
162 } | 156 } |
163 | 157 |
164 static void testParseInt() { | 158 static void testParseInt() { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 testSin(); | 238 testSin(); |
245 testCos(); | 239 testCos(); |
246 testTan(); | 240 testTan(); |
247 testAsin(); | 241 testAsin(); |
248 testAcos(); | 242 testAcos(); |
249 testAtan(); | 243 testAtan(); |
250 testAtan2(); | 244 testAtan2(); |
251 testSqrt(); | 245 testSqrt(); |
252 testLog(); | 246 testLog(); |
253 testExp(); | 247 testExp(); |
254 testPow(); | |
255 testParseInt(); | 248 testParseInt(); |
256 } | 249 } |
257 } | 250 } |
258 | 251 |
259 main() { | 252 main() { |
260 MathTest.testMain(); | 253 MathTest.testMain(); |
261 } | 254 } |
OLD | NEW |