| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 // We temporarily test both the new math library and the old Math | 5 // We temporarily test both the new math library and the old Math |
| 6 // class. This can easily be simplified once we get rid of the Math | 6 // class. This can easily be simplified once we get rid of the Math |
| 7 // class entirely. | 7 // class entirely. |
| 8 library math_test; | 8 library math_test; |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 Expect.equals(0xABCDEF, int.parse(" 0x00000ABCDEF ")); | 202 Expect.equals(0xABCDEF, int.parse(" 0x00000ABCDEF ")); |
| 203 Expect.equals(-0xabcdef, int.parse(" -0x00000abcdef ")); | 203 Expect.equals(-0xabcdef, int.parse(" -0x00000abcdef ")); |
| 204 Expect.equals(-0xABCDEF, int.parse(" -0x00000ABCDEF ")); | 204 Expect.equals(-0xABCDEF, int.parse(" -0x00000ABCDEF ")); |
| 205 Expect.equals(10, int.parse("010")); | 205 Expect.equals(10, int.parse("010")); |
| 206 Expect.equals(-10, int.parse("-010")); | 206 Expect.equals(-10, int.parse("-010")); |
| 207 Expect.equals(10, int.parse(" 010 ")); | 207 Expect.equals(10, int.parse(" 010 ")); |
| 208 Expect.equals(-10, int.parse(" -010 ")); | 208 Expect.equals(-10, int.parse(" -010 ")); |
| 209 Expect.equals(9, int.parse("09")); | 209 Expect.equals(9, int.parse("09")); |
| 210 Expect.equals(9, int.parse(" 09 ")); | 210 Expect.equals(9, int.parse(" 09 ")); |
| 211 Expect.equals(-9, int.parse("-09")); | 211 Expect.equals(-9, int.parse("-09")); |
| 212 Expect.equals(0x1234567890, int.parse("+0x1234567890")); |
| 213 Expect.equals(0x1234567890, int.parse(" +0x1234567890 ")); |
| 214 Expect.equals(0x100, int.parse("+0x100")); |
| 215 Expect.equals(0x100, int.parse(" +0x100 ")); |
| 216 |
| 212 Expect.equals(true, parseIntThrowsFormatException("1b")); | 217 Expect.equals(true, parseIntThrowsFormatException("1b")); |
| 213 Expect.equals(true, parseIntThrowsFormatException(" 1b ")); | 218 Expect.equals(true, parseIntThrowsFormatException(" 1b ")); |
| 214 Expect.equals(true, parseIntThrowsFormatException(" 1 b ")); | 219 Expect.equals(true, parseIntThrowsFormatException(" 1 b ")); |
| 215 Expect.equals(true, parseIntThrowsFormatException("1e2")); | 220 Expect.equals(true, parseIntThrowsFormatException("1e2")); |
| 216 Expect.equals(true, parseIntThrowsFormatException(" 1e2 ")); | 221 Expect.equals(true, parseIntThrowsFormatException(" 1e2 ")); |
| 217 Expect.equals(true, parseIntThrowsFormatException("00x12")); | 222 Expect.equals(true, parseIntThrowsFormatException("00x12")); |
| 218 Expect.equals(true, parseIntThrowsFormatException(" 00x12 ")); | 223 Expect.equals(true, parseIntThrowsFormatException(" 00x12 ")); |
| 219 Expect.equals(true, parseIntThrowsFormatException("-1b")); | 224 Expect.equals(true, parseIntThrowsFormatException("-1b")); |
| 220 Expect.equals(true, parseIntThrowsFormatException(" -1b ")); | 225 Expect.equals(true, parseIntThrowsFormatException(" -1b ")); |
| 221 Expect.equals(true, parseIntThrowsFormatException(" -1 b ")); | 226 Expect.equals(true, parseIntThrowsFormatException(" -1 b ")); |
| 222 Expect.equals(true, parseIntThrowsFormatException("-1e2")); | 227 Expect.equals(true, parseIntThrowsFormatException("-1e2")); |
| 223 Expect.equals(true, parseIntThrowsFormatException(" -1e2 ")); | 228 Expect.equals(true, parseIntThrowsFormatException(" -1e2 ")); |
| 224 Expect.equals(true, parseIntThrowsFormatException("-00x12")); | 229 Expect.equals(true, parseIntThrowsFormatException("-00x12")); |
| 225 Expect.equals(true, parseIntThrowsFormatException(" -00x12 ")); | 230 Expect.equals(true, parseIntThrowsFormatException(" -00x12 ")); |
| 226 Expect.equals(true, parseIntThrowsFormatException(" -00x12 ")); | 231 Expect.equals(true, parseIntThrowsFormatException(" -00x12 ")); |
| 227 Expect.equals(true, parseIntThrowsFormatException("0x0x12")); | 232 Expect.equals(true, parseIntThrowsFormatException("0x0x12")); |
| 228 Expect.equals(true, parseIntThrowsFormatException("0.1")); | 233 Expect.equals(true, parseIntThrowsFormatException("0.1")); |
| 229 Expect.equals(true, parseIntThrowsFormatException("0x3.1")); | 234 Expect.equals(true, parseIntThrowsFormatException("0x3.1")); |
| 230 Expect.equals(true, parseIntThrowsFormatException("5.")); | 235 Expect.equals(true, parseIntThrowsFormatException("5.")); |
| 231 Expect.equals(true, parseIntThrowsFormatException("+-5")); | 236 Expect.equals(true, parseIntThrowsFormatException("+-5")); |
| 232 Expect.equals(true, parseIntThrowsFormatException("-+5")); | 237 Expect.equals(true, parseIntThrowsFormatException("-+5")); |
| 233 Expect.equals(true, parseIntThrowsFormatException("--5")); | 238 Expect.equals(true, parseIntThrowsFormatException("--5")); |
| 234 Expect.equals(true, parseIntThrowsFormatException("++5")); | 239 Expect.equals(true, parseIntThrowsFormatException("++5")); |
| 235 Expect.equals(true, parseIntThrowsFormatException("+ 5")); | 240 Expect.equals(true, parseIntThrowsFormatException("+ 5")); |
| 236 Expect.equals(true, parseIntThrowsFormatException("- 5")); | 241 Expect.equals(true, parseIntThrowsFormatException("- 5")); |
| 237 Expect.equals(true, parseIntThrowsFormatException("")); | 242 Expect.equals(true, parseIntThrowsFormatException("")); |
| 238 Expect.equals(true, parseIntThrowsFormatException(" ")); | 243 Expect.equals(true, parseIntThrowsFormatException(" ")); |
| 239 Expect.equals(true, parseIntThrowsFormatException("+0x1234567890")); | |
| 240 Expect.equals(true, parseIntThrowsFormatException(" +0x1234567890 ")); | |
| 241 Expect.equals(true, parseIntThrowsFormatException("+0x100")); | |
| 242 Expect.equals(true, parseIntThrowsFormatException(" +0x100 ")); | |
| 243 } | 244 } |
| 244 | 245 |
| 245 static testMain() { | 246 static testMain() { |
| 246 testConstants(); | 247 testConstants(); |
| 247 testSin(); | 248 testSin(); |
| 248 testCos(); | 249 testCos(); |
| 249 testTan(); | 250 testTan(); |
| 250 testAsin(); | 251 testAsin(); |
| 251 testAcos(); | 252 testAcos(); |
| 252 testAtan(); | 253 testAtan(); |
| 253 testAtan2(); | 254 testAtan2(); |
| 254 testSqrt(); | 255 testSqrt(); |
| 255 testLog(); | 256 testLog(); |
| 256 testExp(); | 257 testExp(); |
| 257 testPow(); | 258 testPow(); |
| 258 testParseInt(); | 259 testParseInt(); |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 | 262 |
| 262 main() { | 263 main() { |
| 263 MathLibraryTest.testMain(); | 264 MathLibraryTest.testMain(); |
| 264 } | 265 } |
| OLD | NEW |