| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // | 4 // |
| 5 // Dart test program for testing math's pow. | 5 // Dart test program for testing math's pow. |
| 6 | 6 |
| 7 library pow_test; | 7 library pow_test; |
| 8 | 8 |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 import 'dart:math'; | 10 import 'dart:math'; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 18446744073709551616, | 78 18446744073709551616, |
| 79 36893488147419103232, | 79 36893488147419103232, |
| 80 73786976294838206464, | 80 73786976294838206464, |
| 81 147573952589676412928 | 81 147573952589676412928 |
| 82 ]; | 82 ]; |
| 83 | 83 |
| 84 | 84 |
| 85 void main() { | 85 void main() { |
| 86 int exp = 0; | 86 int exp = 0; |
| 87 for (int val in expectedResults) { | 87 for (int val in expectedResults) { |
| 88 Expect.equals(val, pow(2, exp++)); | 88 Expect.equals(val, pow(2, exp)); |
| 89 Expect.equals(val.toDouble(), pow(2, exp.toDouble())); |
| 90 exp++; |
| 89 } | 91 } |
| 92 |
| 90 // Optimize it. | 93 // Optimize it. |
| 91 for (int i = 0; i < 8888; i++) { | 94 for (int i = 0; i < 8888; i++) { |
| 92 pow(2, 3); | 95 pow(2, 3); |
| 96 pow(2.0, 3.0); |
| 93 } | 97 } |
| 94 exp = 0; | 98 exp = 0; |
| 95 for (int val in expectedResults) { | 99 for (int val in expectedResults) { |
| 96 Expect.equals(val, pow(2, exp++)); | 100 Expect.equals(val, pow(2, exp)); |
| 101 Expect.equals(val.toDouble(), pow(2, exp.toDouble())); |
| 102 exp++; |
| 97 } | 103 } |
| 104 // Test Bigints. |
| 105 Expect.equals(5559917313492231481, pow(11, 18)); |
| 106 Expect.equals(672749994932560009201, pow(11, 20)); |
| 98 } | 107 } |
| OLD | NEW |