| 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 // Dart test program to test arithmetic operations. | 4 // Dart test program to test arithmetic operations. |
| 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr | 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr |
| 6 | 6 |
| 7 library arithmetic_test; | 7 library arithmetic_test; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 | 10 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 static int divMod(a, b) => a ~/ b + a % b; | 428 static int divMod(a, b) => a ~/ b + a % b; |
| 429 | 429 |
| 430 static void testSmiDivModDeopt() { | 430 static void testSmiDivModDeopt() { |
| 431 var a = -0x40000000; | 431 var a = -0x40000000; |
| 432 var b = -1; | 432 var b = -1; |
| 433 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, divMod(a, b)); | 433 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, divMod(a, b)); |
| 434 } | 434 } |
| 435 | 435 |
| 436 static double sinCosSub(double a) => sin(a) - cos(a); | 436 static double sinCosSub(double a) => sin(a) - cos(a); |
| 437 | 437 |
| 438 static double sinCosAddCos(double a) => sin(a) * cos(a) + cos(a); |
| 439 |
| 438 static void testSinCos() { | 440 static void testSinCos() { |
| 439 var e = sin(1.234) - cos(1.234); | 441 var e = sin(1.234) - cos(1.234); |
| 442 var f = sin(1.234) * cos(1.234) + cos(1.234); |
| 443 |
| 440 for (var i = 0; i < 20; i++) { | 444 for (var i = 0; i < 20; i++) { |
| 441 Expect.approxEquals(e, sinCosSub(1.234)); | 445 Expect.approxEquals(e, sinCosSub(1.234)); |
| 446 Expect.approxEquals(f, sinCosAddCos(1.234)); |
| 442 } | 447 } |
| 443 Expect.approxEquals(1.0, sinCosSub(3.14159265)); | 448 Expect.approxEquals(1.0, sinCosSub(3.14159265)); |
| 444 Expect.approxEquals(1.0, sinCosSub(3.14159265 / 2.0)); | 449 Expect.approxEquals(1.0, sinCosSub(3.14159265 / 2.0)); |
| 445 } | 450 } |
| 446 | 451 |
| 447 static mySqrt(var x) => sqrt(x); | 452 static mySqrt(var x) => sqrt(x); |
| 448 | 453 |
| 449 static testSqrtDeopt() { | 454 static testSqrtDeopt() { |
| 450 for (var i = 0; i < 10; i++) mySqrt(4.0); | 455 for (var i = 0; i < 10; i++) mySqrt(4.0); |
| 451 Expect.equals(2.0, mySqrt(4.0)); | 456 Expect.equals(2.0, mySqrt(4.0)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 472 testSqrtDeopt(); | 477 testSqrtDeopt(); |
| 473 testDoubleEquality(); | 478 testDoubleEquality(); |
| 474 testSinCos(); | 479 testSinCos(); |
| 475 } | 480 } |
| 476 } | 481 } |
| 477 } | 482 } |
| 478 | 483 |
| 479 main() { | 484 main() { |
| 480 ArithmeticTest.testMain(); | 485 ArithmeticTest.testMain(); |
| 481 } | 486 } |
| OLD | NEW |