OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class Range { |
| 6 final int from; |
| 7 final int to; |
| 8 const Range(this.from, this.to); |
| 9 } |
| 10 |
| 11 class StringTrimTest { |
| 12 static testMain() { |
| 13 var spaces = [ |
| 14 const Range(9, 13), // Control characters, not in the Zs category. |
| 15 const Range(32, 32), |
| 16 const Range(0xa0, 0xa0), |
| 17 const Range(0x1680, 0x1680), |
| 18 const Range(0x180e, 0x180e), |
| 19 const Range(0x2000, 0x200a), |
| 20 // LINE SEPARATOR, category Zl and PARAGRAPH SEPARATOR, category Zp. |
| 21 const Range(0x2028, 0x2029), |
| 22 const Range(0x202f, 0x202f), |
| 23 const Range(0x205f, 0x205f), |
| 24 const Range(0x3000, 0x3000), |
| 25 const Range(0xfeff, 0xfeff)]; // Unicode BOM. |
| 26 for (int range in spaces) { |
| 27 for (int i = range.from - 1; i <= range.to + 1; i++) { |
| 28 print("Check $i"); |
| 29 if (i >= range.from && i <= range.to) { |
| 30 Expect.equals( |
| 31 new String.fromCharCodes([i, 'f'.charCodeAt(0), i]).trim(), 'f'); |
| 32 } else { |
| 33 Expect.isFalse('f' == |
| 34 new String.fromCharCodes([i, 'f'.charCodeAt(0), i]).trim()); |
| 35 } |
| 36 } |
| 37 } |
| 38 // 0x85 NEL Next line is not in the Unicode Zs category and it not special |
| 39 // cased in the ES5 spec either. |
| 40 Expect.isFalse('f' == |
| 41 new String.fromCharCodes([0x85, 'f'.charCodeAt(0), 0x85]).trim()); |
| 42 } |
| 43 } |
| 44 |
| 45 main() { |
| 46 StringTrimTest.testMain(); |
| 47 } |
OLD | NEW |