Chromium Code Reviews| 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 main() { | 5 main() { |
| 6 // Just make sure that we use lower-case characters. | 6 // Test that we accept radix 2 to 36 and that we use lower-case |
| 7 Expect.equals("abcd", (0xabcd).toRadixString(16)); | 7 // letters. |
| 8 } | 8 var expected = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
| 9 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', | |
| 10 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', | |
| 11 'u', 'v', 'w', 'x', 'y', 'z']; | |
| 12 for (var radix = 2; radix < 37; radix++) { | |
| 13 for (var i = 0; i < radix; i++) { | |
| 14 Expect.equals(expected[i], i.toRadixString(radix)); | |
| 15 } | |
| 16 } | |
| 17 | |
| 18 var illegalRadices = [ -1, 0, 1, 37 ]; | |
| 19 for (var radix in illegalRadices) { | |
| 20 try { | |
| 21 42.toRadixString(radix); | |
| 22 Expect.fail("Exception expected"); | |
| 23 } catch (e) { | |
|
Lasse Reichstein Nielsen
2012/09/19 11:43:54
Add "on IllegalArgumentException"?
Mads Ager (google)
2012/09/19 14:16:13
Yes! Thanks, that caught another inconsistency. da
| |
| 24 // Nothing to do. | |
| 25 } | |
| 26 } | |
| 27 } | |
| OLD | NEW |