| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // |
| 5 // Dart test program for testing math's pow. |
| 6 |
| 7 import 'dart:math'; |
| 8 |
| 9 var expectedResults = |
| 10 [ |
| 11 1, |
| 12 2, |
| 13 4, |
| 14 8, |
| 15 16, |
| 16 32, |
| 17 64, |
| 18 128, |
| 19 256, |
| 20 512, |
| 21 1024, |
| 22 2048, |
| 23 4096, |
| 24 8192, |
| 25 16384, |
| 26 32768, |
| 27 65536, |
| 28 131072, |
| 29 262144, |
| 30 524288, |
| 31 1048576, |
| 32 2097152, |
| 33 4194304, |
| 34 8388608, |
| 35 16777216, |
| 36 33554432, |
| 37 67108864, |
| 38 134217728, |
| 39 268435456, |
| 40 536870912, |
| 41 1073741824, |
| 42 2147483648, |
| 43 4294967296, |
| 44 8589934592, |
| 45 17179869184, |
| 46 34359738368, |
| 47 68719476736, |
| 48 137438953472, |
| 49 274877906944, |
| 50 549755813888, |
| 51 1099511627776, |
| 52 2199023255552, |
| 53 4398046511104, |
| 54 8796093022208, |
| 55 17592186044416, |
| 56 35184372088832, |
| 57 70368744177664, |
| 58 140737488355328, |
| 59 281474976710656, |
| 60 562949953421312, |
| 61 1125899906842624, |
| 62 2251799813685248, |
| 63 4503599627370496, |
| 64 9007199254740992, |
| 65 18014398509481984, |
| 66 36028797018963968, |
| 67 72057594037927936, |
| 68 144115188075855872, |
| 69 288230376151711744, |
| 70 576460752303423488, |
| 71 1152921504606846976, |
| 72 2305843009213693952, |
| 73 4611686018427387904, |
| 74 9223372036854775808, |
| 75 18446744073709551616, |
| 76 36893488147419103232, |
| 77 73786976294838206464, |
| 78 147573952589676412928 |
| 79 ]; |
| 80 |
| 81 |
| 82 void main() { |
| 83 int exp = 0; |
| 84 for (int val in expectedResults) { |
| 85 Expect.equals(val, pow(2, exp++)); |
| 86 } |
| 87 // Optimize it. |
| 88 for (int i = 0; i < 8888; i++) { |
| 89 pow(2, 3); |
| 90 } |
| 91 exp = 0; |
| 92 for (int val in expectedResults) { |
| 93 Expect.equals(val, pow(2, exp++)); |
| 94 } |
| 95 } |
| OLD | NEW |