| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class ArithmeticTest { | 6 class ArithmeticTest { |
| 7 | 7 |
| 8 static bool exceptionCaughtParseInt(String s) { | 8 static bool exceptionCaughtParseInt(String s) { |
| 9 try { | 9 try { |
| 10 Math.parseInt(s); | 10 Math.parseInt(s); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Big. | 130 // Big. |
| 131 Expect.equals(false, big.isNegative()); | 131 Expect.equals(false, big.isNegative()); |
| 132 Expect.equals(true, (-big).isNegative()); | 132 Expect.equals(true, (-big).isNegative()); |
| 133 // Double. | 133 // Double. |
| 134 // TODO(srdjan): enable the following test once isNegative works. | 134 // TODO(srdjan): enable the following test once isNegative works. |
| 135 // Expect.equals(true, (-0.0).isNegative()); | 135 // Expect.equals(true, (-0.0).isNegative()); |
| 136 Expect.equals(false, (0.0).isNegative()); | 136 Expect.equals(false, (0.0).isNegative()); |
| 137 Expect.equals(false, (2.0).isNegative()); | 137 Expect.equals(false, (2.0).isNegative()); |
| 138 Expect.equals(true, (-2.0).isNegative()); | 138 Expect.equals(true, (-2.0).isNegative()); |
| 139 | 139 |
| 140 double negateDouble(double x) { |
| 141 return -x; |
| 142 } |
| 143 |
| 144 Expect.isTrue(negateDouble(0.0).isNegative()); |
| 145 Expect.isFalse(negateDouble(-0.0).isNegative()); |
| 146 Expect.isTrue(negateDouble(3.5e3).isNegative()); |
| 147 Expect.isFalse(negateDouble(-3.5e3).isNegative()); |
| 148 |
| 149 |
| 140 // Constants. | 150 // Constants. |
| 141 final nan = 0.0/0.0; | 151 final nan = 0.0/0.0; |
| 142 final infinity = 1.0/0.0; | 152 final infinity = 1.0/0.0; |
| 143 | 153 |
| 144 // -- isInfinite --. | 154 // -- isInfinite --. |
| 145 // Smi. | 155 // Smi. |
| 146 Expect.equals(false, (0).isInfinite()); | 156 Expect.equals(false, (0).isInfinite()); |
| 147 Expect.equals(false, (1).isInfinite()); | 157 Expect.equals(false, (1).isInfinite()); |
| 148 Expect.equals(false, (-1).isInfinite()); | 158 Expect.equals(false, (-1).isInfinite()); |
| 149 // Big. | 159 // Big. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 static testMain() { | 408 static testMain() { |
| 399 for (int i = 0; i < 1500; i++) { | 409 for (int i = 0; i < 1500; i++) { |
| 400 runOne(); | 410 runOne(); |
| 401 } | 411 } |
| 402 } | 412 } |
| 403 } | 413 } |
| 404 | 414 |
| 405 main() { | 415 main() { |
| 406 ArithmeticTest.testMain(); | 416 ArithmeticTest.testMain(); |
| 407 } | 417 } |
| OLD | NEW |