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

Side by Side Diff: dart/tests/compiler/dart2js_extra/string_escape_test.dart

Issue 10558025: Fix build breakage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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 // Test that string escapes work correctly. 5 // Test that string escapes work correctly.
6 6
7 testSingleCharacterEscapes() { 7 testSingleCharacterEscapes() {
8 List/*<String>*/ examples = [ 8 List/*<String>*/ examples = [
9 "\b\f\n\r\t\v", 9 "\b\f\n\r\t\v",
10 '\b\f\n\r\t\v', 10 '\b\f\n\r\t\v',
(...skipping 12 matching lines...) Expand all
23 Expect.equals(@'"', """\""""); 23 Expect.equals(@'"', """\"""");
24 Expect.equals(@"'", '''\''''); 24 Expect.equals(@"'", '''\'''');
25 Expect.equals(@'" "', """" \""""); 25 Expect.equals(@'" "', """" \"""");
26 Expect.equals(@"' '", '''' \''''); 26 Expect.equals(@"' '", '''' \'''');
27 Expect.equals(@'"" ', """"" """); 27 Expect.equals(@'"" ', """"" """);
28 Expect.equals(@"'' ", ''''' '''); 28 Expect.equals(@"'' ", ''''' ''');
29 } 29 }
30 30
31 testXEscapes() { 31 testXEscapes() {
32 var allBytes = 32 var allBytes =
33 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + 33 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
34 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + 34 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
35 "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" + 35 "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
36 "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" + 36 "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
37 "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" + 37 "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
38 "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" + 38 "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
39 "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" + 39 "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
40 "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" + 40 "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
41 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" + 41 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
42 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" + 42 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
43 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" + 43 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
44 "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" + 44 "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
45 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" + 45 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
46 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" + 46 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
47 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" + 47 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
48 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"; 48 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
49 Expect.equals(256, allBytes.length); 49 Expect.equals(256, allBytes.length);
50 for (int i = 0; i < 256; i++) { 50 for (int i = 0; i < 256; i++) {
51 Expect.equals(i, allBytes.charCodeAt(i)); 51 Expect.equals(i, allBytes.charCodeAt(i));
52 } 52 }
53 } 53 }
54 54
55 testUEscapes() { 55 testUEscapes() {
56 List/*String*/ examples = 56 List/*String*/ examples =
57 ["\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff" + 57 ["\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff"
58 "\u0100\u1000\ud7ff\ue000\uffff", 58 "\u0100\u1000\ud7ff\ue000\uffff",
59 '\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff' + 59 '\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff'
60 '\u0100\u1000\ud7ff\ue000\uffff', 60 '\u0100\u1000\ud7ff\ue000\uffff',
61 """\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff""" + 61 """\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff"""
62 """\u0100\u1000\ud7ff\ue000\uffff""", 62 """\u0100\u1000\ud7ff\ue000\uffff""",
63 '''\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff''' + 63 '''\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff'''
64 '''\u0100\u1000\ud7ff\ue000\uffff''']; 64 '''\u0100\u1000\ud7ff\ue000\uffff'''];
65 List/*<int>*/ values = [0, 1, 0x22, 0x27, 0x5c, 0x7f, 0x80, 0xff, 65 List/*<int>*/ values = [0, 1, 0x22, 0x27, 0x5c, 0x7f, 0x80, 0xff,
66 0x100, 0x1000, 0xd7ff, 0xe000, 0xffff]; 66 0x100, 0x1000, 0xd7ff, 0xe000, 0xffff];
67 for (String s in examples) { 67 for (String s in examples) {
68 Expect.equals(values.length, s.length); 68 Expect.equals(values.length, s.length);
69 for (int i = 0; i < values.length; i++) { 69 for (int i = 0; i < values.length; i++) {
70 Expect.equals(values[i], s.charCodeAt(i)); 70 Expect.equals(values[i], s.charCodeAt(i));
71 } 71 }
72 } 72 }
73 // No characters above 0xffff until Leg supports that. 73 // No characters above 0xffff until Leg supports that.
74 var long = 74 var long =
75 "\u{0}\u{00}\u{000}\u{0000}\u{00000}\u{000000}" + 75 "\u{0}\u{00}\u{000}\u{0000}\u{00000}\u{000000}"
76 "\u{1}\u{01}\u{001}\u{00001}" + 76 "\u{1}\u{01}\u{001}\u{00001}"
77 "\u{ffff}\u{0ffff}\u{00ffff}"; 77 "\u{ffff}\u{0ffff}\u{00ffff}";
78 var longValues = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0xffff, 0xffff, 0xffff]; 78 var longValues = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0xffff, 0xffff, 0xffff];
79 Expect.equals(longValues.length, long.length); 79 Expect.equals(longValues.length, long.length);
80 for (int i = 0; i < longValues.length; i++) { 80 for (int i = 0; i < longValues.length; i++) {
81 Expect.equals(longValues[i], long.charCodeAt(i)); 81 Expect.equals(longValues[i], long.charCodeAt(i));
82 } 82 }
83 } 83 }
84 84
85 testIdentityEscapes() { 85 testIdentityEscapes() {
86 // All non-control ASCII characters escaped, except those with special 86 // All non-control ASCII characters escaped, except those with special
87 // meaning: b, f, n, r, t, u, v, and x (replaced by \x00). 87 // meaning: b, f, n, r, t, u, v, and x (replaced by \x00).
88 var asciiLiterals = 88 var asciiLiterals =
89 "\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>" + 89 "\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>"
90 "\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\\\]" + 90 "\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\\\]"
91 "\^\_\`\a\x00\c\d\e\x00\g\h\i\j\k\l\m\x00\o\p\q\x00\s\x00\x00\x00" + 91 "\^\_\`\a\x00\c\d\e\x00\g\h\i\j\k\l\m\x00\o\p\q\x00\s\x00\x00\x00"
92 "\w\x00\y\z\{\|\}\~\"; 92 "\w\x00\y\z\{\|\}\~\";
93 93
94 Expect.equals(128 - 32, asciiLiterals.length); 94 Expect.equals(128 - 32, asciiLiterals.length);
95 for (int i = 32; i < 128; i++) { 95 for (int i = 32; i < 128; i++) {
96 int code = asciiLiterals.charCodeAt(i - 32); 96 int code = asciiLiterals.charCodeAt(i - 32);
97 if (code != 0) { 97 if (code != 0) {
98 Expect.equals(i, code); 98 Expect.equals(i, code);
99 } 99 }
100 } 100 }
101 } 101 }
(...skipping 24 matching lines...) Expand all
126 testUEscapes(); 126 testUEscapes();
127 // Test \b, \f, \n, \r, \t, \v. 127 // Test \b, \f, \n, \r, \t, \v.
128 testSingleCharacterEscapes(); 128 testSingleCharacterEscapes();
129 // Test all other single character (identity) escaeps. 129 // Test all other single character (identity) escaeps.
130 testIdentityEscapes(); 130 testIdentityEscapes();
131 // Test that quotes are handled correctly. 131 // Test that quotes are handled correctly.
132 testQuotes(); 132 testQuotes();
133 // Test that raw strings are raw. 133 // Test that raw strings are raw.
134 testRawStrings(); 134 testRawStrings();
135 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698