| 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 var f = sin(1.234) * cos(1.234) + cos(1.234); | 442 var f = sin(1.234) * cos(1.234) + cos(1.234); |
| 443 | 443 |
| 444 for (var i = 0; i < 20; i++) { | 444 for (var i = 0; i < 20; i++) { |
| 445 Expect.approxEquals(e, sinCosSub(1.234)); | 445 Expect.approxEquals(e, sinCosSub(1.234)); |
| 446 Expect.approxEquals(f, sinCosAddCos(1.234)); | 446 Expect.approxEquals(f, sinCosAddCos(1.234)); |
| 447 } | 447 } |
| 448 Expect.approxEquals(1.0, sinCosSub(3.14159265)); | 448 Expect.approxEquals(1.0, sinCosSub(3.14159265)); |
| 449 Expect.approxEquals(1.0, sinCosSub(3.14159265 / 2.0)); | 449 Expect.approxEquals(1.0, sinCosSub(3.14159265 / 2.0)); |
| 450 } | 450 } |
| 451 | 451 |
| 452 // Test fix for issue 16592. |
| 453 static void testSinCosNoUse() { |
| 454 for (var i = 0; i < 20; i++) { |
| 455 sin(i); |
| 456 cos(i); |
| 457 } |
| 458 } |
| 459 |
| 452 static mySqrt(var x) => sqrt(x); | 460 static mySqrt(var x) => sqrt(x); |
| 453 | 461 |
| 454 static testSqrtDeopt() { | 462 static testSqrtDeopt() { |
| 455 for (var i = 0; i < 10; i++) mySqrt(4.0); | 463 for (var i = 0; i < 10; i++) mySqrt(4.0); |
| 456 Expect.equals(2.0, mySqrt(4.0)); | 464 Expect.equals(2.0, mySqrt(4.0)); |
| 457 Expect.throws(() => mySqrt("abc")); | 465 Expect.throws(() => mySqrt("abc")); |
| 458 } | 466 } |
| 459 | 467 |
| 460 static self_equality(x) { | 468 static self_equality(x) { |
| 461 return x == x; | 469 return x == x; |
| 462 } | 470 } |
| 463 | 471 |
| 464 static testDoubleEquality() { | 472 static testDoubleEquality() { |
| 465 Expect.isFalse(self_equality(double.NAN)); | 473 Expect.isFalse(self_equality(double.NAN)); |
| 466 for (int i = 0; i < 20; i++) { | 474 for (int i = 0; i < 20; i++) { |
| 467 self_equality(3.0); | 475 self_equality(3.0); |
| 468 } | 476 } |
| 469 Expect.isFalse(self_equality(double.NAN)); | 477 Expect.isFalse(self_equality(double.NAN)); |
| 470 } | 478 } |
| 471 | 479 |
| 472 static testMain() { | 480 static testMain() { |
| 473 for (int i = 0; i < 20; i++) { | 481 for (int i = 0; i < 20; i++) { |
| 474 runOne(); | 482 runOne(); |
| 475 testSmiDivDeopt(); | 483 testSmiDivDeopt(); |
| 476 testSmiDivModDeopt(); | 484 testSmiDivModDeopt(); |
| 477 testSqrtDeopt(); | 485 testSqrtDeopt(); |
| 478 testDoubleEquality(); | 486 testDoubleEquality(); |
| 479 testSinCos(); | 487 testSinCos(); |
| 488 testSinCosNoUse(); |
| 480 } | 489 } |
| 481 } | 490 } |
| 482 } | 491 } |
| 483 | 492 |
| 484 main() { | 493 main() { |
| 485 ArithmeticTest.testMain(); | 494 ArithmeticTest.testMain(); |
| 486 } | 495 } |
| OLD | NEW |