| 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 |
| 5 main() { | 7 main() { |
| 6 Expect.equals("A", new String.fromCharCode(65)); | 8 Expect.equals("A", new String.fromCharCode(65)); |
| 7 Expect.equals("B", new String.fromCharCode(66)); | 9 Expect.equals("B", new String.fromCharCode(66)); |
| 8 var gClef = new String.fromCharCode(0x1D11E); | 10 var gClef = new String.fromCharCode(0x1D11E); |
| 9 Expect.equals(2, gClef.length); | 11 Expect.equals(2, gClef.length); |
| 10 Expect.equals(0xD834, gClef.codeUnitAt(0)); | 12 Expect.equals(0xD834, gClef.codeUnitAt(0)); |
| 11 Expect.equals(0xDD1E, gClef.codeUnitAt(1)); | 13 Expect.equals(0xDD1E, gClef.codeUnitAt(1)); |
| 12 | 14 |
| 13 // Unmatched surrogates. | 15 // Unmatched surrogates. |
| 14 var unmatched = new String.fromCharCode(0xD800); | 16 var unmatched = new String.fromCharCode(0xD800); |
| 15 Expect.equals(1, unmatched.length); | 17 Expect.equals(1, unmatched.length); |
| 16 Expect.equals(0xD800, unmatched.codeUnitAt(0)); | 18 Expect.equals(0xD800, unmatched.codeUnitAt(0)); |
| 17 unmatched = new String.fromCharCode(0xDC00); | 19 unmatched = new String.fromCharCode(0xDC00); |
| 18 Expect.equals(1, unmatched.length); | 20 Expect.equals(1, unmatched.length); |
| 19 Expect.equals(0xDC00, unmatched.codeUnitAt(0)); | 21 Expect.equals(0xDC00, unmatched.codeUnitAt(0)); |
| 20 | 22 |
| 21 Expect.throws(() => new String.fromCharCode(-1), | 23 Expect.throws(() => new String.fromCharCode(-1), |
| 22 (e) => e is ArgumentError); | 24 (e) => e is ArgumentError); |
| 23 | 25 |
| 24 // Invalid code point. | 26 // Invalid code point. |
| 25 Expect.throws(() => new String.fromCharCode(0x110000), | 27 Expect.throws(() => new String.fromCharCode(0x110000), |
| 26 (e) => e is ArgumentError); | 28 (e) => e is ArgumentError); |
| 27 | 29 |
| 28 Expect.throws(() => new String.fromCharCode(0x110001), | 30 Expect.throws(() => new String.fromCharCode(0x110001), |
| 29 (e) => e is ArgumentError); | 31 (e) => e is ArgumentError); |
| 30 } | 32 } |
| OLD | NEW |