Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: tests/standalone/pow_test.dart

Issue 14619027: Fix for issue 10534. Implement int.pow correctly. Note that int.pow is considerably slower than dou… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/math_patch.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « runtime/lib/math_patch.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698