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"; | |
6 | |
7 void main() { | 5 void main() { |
8 bool checkedMode = false; | 6 bool checkedMode = false; |
9 assert(checkedMode = true); | 7 assert(checkedMode = true); |
10 | 8 |
11 for (int i = 0; i < 36 * 36 + 1; i++) { | 9 for (int i = 0; i < 36 * 36 + 1; i++) { |
12 for (int r = 2; r <= 36; r++) { | 10 for (int r = 2; r <= 36; r++) { |
13 String radixString = i.toRadixString(r); | 11 String radixString = i.toRadixString(r); |
14 Expect.equals(i, int.parse(radixString, radix: r), ""); | 12 Expect.equals(i, int.parse(radixString, radix: r), ""); |
15 Expect.equals(i, int.parse(" $radixString", radix: r), ""); | 13 Expect.equals(i, int.parse(" $radixString", radix: r), ""); |
16 Expect.equals(i, int.parse("$radixString ", radix: r), ""); | 14 Expect.equals(i, int.parse("$radixString ", radix: r), ""); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 testBadArguments("0", 0); | 79 testBadArguments("0", 0); |
82 testBadArguments("0", 1); | 80 testBadArguments("0", 1); |
83 testBadArguments("0", 37); | 81 testBadArguments("0", 37); |
84 | 82 |
85 // If handleError isn't an unary function, and it's called, it also throws | 83 // If handleError isn't an unary function, and it's called, it also throws |
86 // (either TypeError in checked mode, or some failure in unchecked mode). | 84 // (either TypeError in checked mode, or some failure in unchecked mode). |
87 Expect.throws(() => int.parse("9", radix: 8, onError: "not a function")); | 85 Expect.throws(() => int.parse("9", radix: 8, onError: "not a function")); |
88 Expect.throws(() => int.parse("9", radix: 8, onError: () => 42)); | 86 Expect.throws(() => int.parse("9", radix: 8, onError: () => 42)); |
89 Expect.throws(() => int.parse("9", radix: 8, onError: (v1, v2) => 42)); | 87 Expect.throws(() => int.parse("9", radix: 8, onError: (v1, v2) => 42)); |
90 } | 88 } |
OLD | NEW |