Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: tests/corelib/string_trimlr_test.dart

Issue 2733353002: Remove U+180E from whitespace in js_runtime and tests (Closed)
Patch Set: also corelib_strong Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Characters with Whitespace property (Unicode 6.2). 7 // Characters with Whitespace property (Unicode 6.3).
8 // 0009..000D ; White_Space # Cc <control-0009>..<control-000D> 8 // 0009..000D ; White_Space # Cc <control-0009>..<control-000D>
9 // 0020 ; White_Space # Zs SPACE 9 // 0020 ; White_Space # Zs SPACE
10 // 0085 ; White_Space # Cc <control-0085> 10 // 0085 ; White_Space # Cc <control-0085>
11 // 00A0 ; White_Space # Zs NO-BREAK SPACE 11 // 00A0 ; White_Space # Zs NO-BREAK SPACE
12 // 1680 ; White_Space # Zs OGHAM SPACE MARK 12 // 1680 ; White_Space # Zs OGHAM SPACE MARK
13 // 180E ; White_Space # Zs MONGOLIAN VOWEL SEPARATOR
14 // 2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE 13 // 2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE
15 // 2028 ; White_Space # Zl LINE SEPARATOR 14 // 2028 ; White_Space # Zl LINE SEPARATOR
16 // 2029 ; White_Space # Zp PARAGRAPH SEPARATOR 15 // 2029 ; White_Space # Zp PARAGRAPH SEPARATOR
17 // 202F ; White_Space # Zs NARROW NO-BREAK SPACE 16 // 202F ; White_Space # Zs NARROW NO-BREAK SPACE
18 // 205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE 17 // 205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE
19 // 3000 ; White_Space # Zs IDEOGRAPHIC SPACE 18 // 3000 ; White_Space # Zs IDEOGRAPHIC SPACE
20 // And BOM: 19 // And BOM:
21 // FEFF ; Byte order mark. 20 // FEFF ; Byte order mark.
22 const WHITESPACE = const [ 21 const WHITESPACE = const [
23 0x09, 22 0x09,
24 0x0A, 23 0x0A,
25 0x0B, 24 0x0B,
26 0x0C, 25 0x0C,
27 0x0D, 26 0x0D,
28 0x20, 27 0x20,
29 0x85, 28 0x85,
30 0xA0, 29 0xA0,
31 0x1680, 30 0x1680,
32 0x180E,
33 0x2000, 31 0x2000,
34 0x2001, 32 0x2001,
35 0x2002, 33 0x2002,
36 0x2003, 34 0x2003,
37 0x2004, 35 0x2004,
38 0x2005, 36 0x2005,
39 0x2006, 37 0x2006,
40 0x2007, 38 0x2007,
41 0x2008, 39 0x2008,
42 0x2009, 40 0x2009,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Empty strings. 80 // Empty strings.
83 Expect.identical("", "".trimLeft()); 81 Expect.identical("", "".trimLeft());
84 Expect.identical("", "".trimRight()); 82 Expect.identical("", "".trimRight());
85 83
86 // Test all BMP chars and one surrogate pair. 84 // Test all BMP chars and one surrogate pair.
87 for (int i = 0, j = 0; i <= 0x10000; i++) { 85 for (int i = 0, j = 0; i <= 0x10000; i++) {
88 if (j < WHITESPACE.length && i == WHITESPACE[j]) { 86 if (j < WHITESPACE.length && i == WHITESPACE[j]) {
89 j++; 87 j++;
90 continue; 88 continue;
91 } 89 }
92 // U+200b is currently being treated as whitespace by some JS engines. 90 // See below for these exceptions.
93 // Should be fixed in tip-of-tree V8 per 2014-02-10. 91 if (i == 0x180E) continue;
94 // This line makes string_trimlr_test/none fail but /01 succeede where 92 if (i == 0x200B) continue;
95 // this bug is in the JS. Both succeede on the VM and where the bug is
96 // not. Remove this line and comment if all JS engines fix it.
97 if (i == 0x200b) continue; /// 01: ok
98 93
99 var s = new String.fromCharCode(i); 94 var s = new String.fromCharCode(i);
100 Expect.identical(s, s.trimLeft()); 95 Expect.identical(s, s.trimLeft());
101 Expect.identical(s, s.trimRight()); 96 Expect.identical(s, s.trimRight());
102 } 97 }
98
99 // U+200b is currently being treated as whitespace by some JS engines.
100 // string_trimlr_test/01 fails on these engines.
101 // Should be fixed in tip-of-tree V8 per 2014-02-10.
102 var s200B = new String.fromCharCode(0x200B);
103 Expect.identical(s200B, s200B.trimLeft()); /// 01: ok
104 Expect.identical(s200B, s200B.trimRight()); /// 01: ok
105
106 // U+180E ceased to be whitespace in Unicode version 6.3.0
107 // string_trimlr_test/02 fails on implementations using earlier versions.
108 var s180E = new String.fromCharCode(0x180E);
109 Expect.identical(s180E, s180E.trimLeft()); /// 02: ok
110 Expect.identical(s180E, s180E.trimRight()); /// 02: ok
103 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698