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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 main() { | 7 main() { |
8 /// Test that converting [value] to a string gives [expect]. | 8 /// Test that converting [value] to a string gives [expect]. |
9 /// Also test that `-value` gives `"-"+expect`. | 9 /// Also test that `-value` gives `"-"+expect`. |
10 test(int value, String expect) { | 10 test(int value, String expect) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 test(0x7ffffffffffff, "2251799813685247"); | 44 test(0x7ffffffffffff, "2251799813685247"); |
45 test(0x8000000000000, "2251799813685248"); | 45 test(0x8000000000000, "2251799813685248"); |
46 test(0x8000000000001, "2251799813685249"); | 46 test(0x8000000000001, "2251799813685249"); |
47 // ~2^52. | 47 // ~2^52. |
48 test(0xfffffffffffff, "4503599627370495"); | 48 test(0xfffffffffffff, "4503599627370495"); |
49 test(0x10000000000000, "4503599627370496"); | 49 test(0x10000000000000, "4503599627370496"); |
50 test(0x10000000000001, "4503599627370497"); | 50 test(0x10000000000001, "4503599627370497"); |
51 // ~2^53. | 51 // ~2^53. |
52 test(0x1fffffffffffff, "9007199254740991"); | 52 test(0x1fffffffffffff, "9007199254740991"); |
53 test(0x20000000000000, "9007199254740992"); | 53 test(0x20000000000000, "9007199254740992"); |
54 test(0x20000000000001, "9007199254740993"); // /// 01: ok | 54 test(0x20000000000001, "9007199254740993"); // //# 01: ok |
55 // ~2^62. | 55 // ~2^62. |
56 test(0x3fffffffffffffff, "4611686018427387903"); // /// 01: continued | 56 test(0x3fffffffffffffff, "4611686018427387903"); // //# 01: continued |
57 test(0x4000000000000000, "4611686018427387904"); // /// 01: continued | 57 test(0x4000000000000000, "4611686018427387904"); // //# 01: continued |
58 test(0x4000000000000001, "4611686018427387905"); // /// 01: continued | 58 test(0x4000000000000001, "4611686018427387905"); // //# 01: continued |
59 // ~2^63. | 59 // ~2^63. |
60 test(0x7fffffffffffffff, "9223372036854775807"); // /// 01: continued | 60 test(0x7fffffffffffffff, "9223372036854775807"); // //# 01: continued |
61 test(0x8000000000000000, "9223372036854775808"); // /// 01: continued | 61 test(0x8000000000000000, "9223372036854775808"); // //# 01: continued |
62 test(0x8000000000000001, "9223372036854775809"); // /// 01: continued | 62 test(0x8000000000000001, "9223372036854775809"); // //# 01: continued |
63 // ~2^64. | 63 // ~2^64. |
64 test(0xffffffffffffffff, "18446744073709551615"); // /// 01: continued | 64 test(0xffffffffffffffff, "18446744073709551615"); // //# 01: continued |
65 test(0x10000000000000000, "18446744073709551616"); // /// 01: continued | 65 test(0x10000000000000000, "18446744073709551616"); // //# 01: continued |
66 test(0x10000000000000001, "18446744073709551617"); // /// 01: continued | 66 test(0x10000000000000001, "18446744073709551617"); // //# 01: continued |
67 // Big bignum. | 67 // Big bignum. |
68 test(123456789012345678901234567890, // /// 01: continued | 68 test(123456789012345678901234567890, // //# 01: continued |
69 "123456789012345678901234567890"); // /// 01: continued | 69 "123456789012345678901234567890"); // //# 01: continued |
70 | 70 |
71 // Decimal special cases. | 71 // Decimal special cases. |
72 | 72 |
73 int number = 10; | 73 int number = 10; |
74 // Numbers 99..99, 100...00, and 100..01 up to 23 digits. | 74 // Numbers 99..99, 100...00, and 100..01 up to 23 digits. |
75 for (int i = 1; i < 15; i++) { // Works in dart2js up to 10^15. | 75 for (int i = 1; i < 15; i++) { // Works in dart2js up to 10^15. |
76 test(number - 1, "9" * i); | 76 test(number - 1, "9" * i); |
77 test(number, "1" + "0" * i); | 77 test(number, "1" + "0" * i); |
78 test(number + 1, "1" + "0" * (i - 1) + "1"); | 78 test(number + 1, "1" + "0" * (i - 1) + "1"); |
79 number *= 10; | 79 number *= 10; |
80 } | 80 } |
81 // Fails to represent exactly in dart2js. | 81 // Fails to represent exactly in dart2js. |
82 for (int i = 15; i < 22; i++) { // /// 01: continued | 82 for (int i = 15; i < 22; i++) { // //# 01: continued |
83 test(number - 1, "9" * i); // /// 01: continued | 83 test(number - 1, "9" * i); // //# 01: continued |
84 test(number, "1" + "0" * i); // /// 01: continued | 84 test(number, "1" + "0" * i); // //# 01: continued |
85 test(number + 1, "1" + "0" * (i - 1) + "1"); // /// 01: continued | 85 test(number + 1, "1" + "0" * (i - 1) + "1"); // //# 01: continued |
86 number *= 10; // /// 01: continued | 86 number *= 10; // //# 01: continued |
87 } // /// 01: continued | 87 } // //# 01: continued |
88 } | 88 } |
OLD | NEW |