| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 Expect.equals(5.5, a / b); | 48 Expect.equals(5.5, a / b); |
| 49 Expect.equals(2.0, 10 / 5); | 49 Expect.equals(2.0, 10 / 5); |
| 50 Expect.equals(2, a % b); | 50 Expect.equals(2, a % b); |
| 51 Expect.equals(2, a.remainder(b)); | 51 Expect.equals(2, a.remainder(b)); |
| 52 // Smi corner cases. | 52 // Smi corner cases. |
| 53 for (int i = 0; i < 80; i++) { | 53 for (int i = 0; i < 80; i++) { |
| 54 a = -(1 << i); | 54 a = -(1 << i); |
| 55 b = -1; | 55 b = -1; |
| 56 Expect.equals(1 << i, a ~/ b); | 56 Expect.equals(1 << i, a ~/ b); |
| 57 } | 57 } |
| 58 for (int i = 0; i < 80; i++) { | |
| 59 a = -1 << i; | |
| 60 b = -1; | |
| 61 Expect.equals(1 << i, a ~/ b); | |
| 62 } | |
| 63 a = 22; | 58 a = 22; |
| 64 b = 4.0; | 59 b = 4.0; |
| 65 // Smi & double. | 60 // Smi & double. |
| 66 Expect.equals(26.0, a + b); | 61 Expect.equals(26.0, a + b); |
| 67 Expect.equals(18.0, a - b); | 62 Expect.equals(18.0, a - b); |
| 68 Expect.equals(88.0, a * b); | 63 Expect.equals(88.0, a * b); |
| 69 Expect.equals(5.0, a ~/ b); | 64 Expect.equals(5.0, a ~/ b); |
| 70 Expect.equals(5.5, a / b); | 65 Expect.equals(5.5, a / b); |
| 71 Expect.equals(2.0, a % b); | 66 Expect.equals(2.0, a % b); |
| 72 Expect.equals(2.0, a.remainder(b)); | 67 Expect.equals(2.0, a.remainder(b)); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 for (int i = 0; i < 1500; i++) { | 424 for (int i = 0; i < 1500; i++) { |
| 430 runOne(); | 425 runOne(); |
| 431 testSmiDivDeopt(); | 426 testSmiDivDeopt(); |
| 432 } | 427 } |
| 433 } | 428 } |
| 434 } | 429 } |
| 435 | 430 |
| 436 main() { | 431 main() { |
| 437 ArithmeticTest.testMain(); | 432 ArithmeticTest.testMain(); |
| 438 } | 433 } |
| OLD | NEW |