| 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 | 5 |
| 6 library arithmetic_test; | 6 library arithmetic_test; |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 class ArithmeticTest { | 9 class ArithmeticTest { |
| 10 | 10 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 412 } |
| 413 | 413 |
| 414 static int div(a, b) => a ~/ b; | 414 static int div(a, b) => a ~/ b; |
| 415 | 415 |
| 416 static void testSmiDivDeopt() { | 416 static void testSmiDivDeopt() { |
| 417 var a = -0x40000000; | 417 var a = -0x40000000; |
| 418 var b = -1; | 418 var b = -1; |
| 419 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, div(a, b)); | 419 for (var i = 0; i < 10; i++) Expect.equals(0x40000000, div(a, b)); |
| 420 } | 420 } |
| 421 | 421 |
| 422 static mySqrt(var x) => sqrt(x); |
| 423 |
| 424 static testSqrtDeopt() { |
| 425 for (var i = 0; i < 10; i++) mySqrt(4.0); |
| 426 Expect.equals(2.0, mySqrt(4.0)); |
| 427 Expect.throws(() => mySqrt("abc")); |
| 428 } |
| 429 |
| 422 static testMain() { | 430 static testMain() { |
| 423 for (int i = 0; i < 1500; i++) { | 431 for (int i = 0; i < 1500; i++) { |
| 424 runOne(); | 432 runOne(); |
| 425 testSmiDivDeopt(); | 433 testSmiDivDeopt(); |
| 434 testSqrtDeopt(); |
| 426 } | 435 } |
| 427 } | 436 } |
| 428 } | 437 } |
| 429 | 438 |
| 430 main() { | 439 main() { |
| 431 ArithmeticTest.testMain(); | 440 ArithmeticTest.testMain(); |
| 432 } | 441 } |
| OLD | NEW |