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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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) 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"; 5 import "package:expect/expect.dart";
6 6
7 // Test that string escapes work correctly. 7 // Test that string escapes work correctly.
8 8
9 testSingleCharacterEscapes() { 9 testSingleCharacterEscapes() {
10 List/*<String>*/ examples = [ 10 List/*<String>*/ examples = [
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" 48 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
49 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" 49 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
50 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"; 50 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
51 Expect.equals(256, allBytes.length); 51 Expect.equals(256, allBytes.length);
52 for (int i = 0; i < 256; i++) { 52 for (int i = 0; i < 256; i++) {
53 Expect.equals(i, allBytes.codeUnitAt(i)); 53 Expect.equals(i, allBytes.codeUnitAt(i));
54 } 54 }
55 } 55 }
56 56
57 testUEscapes() { 57 testUEscapes() {
58 List/*String*/ examples = 58 List /*String*/ examples = [
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 '''\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff''' 65 '''\u0000\u0001\u0022\u0027\u005c\u007f\u0080\u00ff'''
66 '''\u0100\u1000\ud7ff\ue000\uffff''']; 66 '''\u0100\u1000\ud7ff\ue000\uffff'''
67 List/*<int>*/ values = [0, 1, 0x22, 0x27, 0x5c, 0x7f, 0x80, 0xff, 67 ];
68 0x100, 0x1000, 0xd7ff, 0xe000, 0xffff]; 68 List/*<int>*/ values = [
69 0,
70 1,
71 0x22,
72 0x27,
73 0x5c,
74 0x7f,
75 0x80,
76 0xff,
77 0x100,
78 0x1000,
79 0xd7ff,
80 0xe000,
81 0xffff
82 ];
69 for (String s in examples) { 83 for (String s in examples) {
70 Expect.equals(values.length, s.length); 84 Expect.equals(values.length, s.length);
71 for (int i = 0; i < values.length; i++) { 85 for (int i = 0; i < values.length; i++) {
72 Expect.equals(values[i], s.codeUnitAt(i)); 86 Expect.equals(values[i], s.codeUnitAt(i));
73 } 87 }
74 } 88 }
75 // No characters above 0xffff until Leg supports that. 89 // No characters above 0xffff until Leg supports that.
76 var long = 90 var long = "\u{0}\u{00}\u{000}\u{0000}\u{00000}\u{000000}"
77 "\u{0}\u{00}\u{000}\u{0000}\u{00000}\u{000000}"
78 "\u{1}\u{01}\u{001}\u{00001}" 91 "\u{1}\u{01}\u{001}\u{00001}"
79 "\u{ffff}\u{0ffff}\u{00ffff}"; 92 "\u{ffff}\u{0ffff}\u{00ffff}";
80 var longValues = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0xffff, 0xffff, 0xffff]; 93 var longValues = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0xffff, 0xffff, 0xffff];
81 Expect.equals(longValues.length, long.length); 94 Expect.equals(longValues.length, long.length);
82 for (int i = 0; i < longValues.length; i++) { 95 for (int i = 0; i < longValues.length; i++) {
83 Expect.equals(longValues[i], long.codeUnitAt(i)); 96 Expect.equals(longValues[i], long.codeUnitAt(i));
84 } 97 }
85 } 98 }
86 99
87 testIdentityEscapes() { 100 testIdentityEscapes() {
88 // All non-control ASCII characters escaped, except those with special 101 // All non-control ASCII characters escaped, except those with special
89 // meaning: b, f, n, r, t, u, v, and x (replaced by \x00). 102 // meaning: b, f, n, r, t, u, v, and x (replaced by \x00).
90 var asciiLiterals = 103 var asciiLiterals =
91 "\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>" 104 "\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>"
92 "\?\@\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\[\\\]" 105 "\?\@\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\[\\\]"
93 "\^\_\`\a\x00\c\d\e\x00\g\h\i\j\k\l\m\x00\o\p\q\x00\s\x00\x00\x00" 106 "\^\_\`\a\x00\c\d\e\x00\g\h\i\j\k\l\m\x00\o\p\q\x00\s\x00\x00\x00"
94 "\w\x00\y\z\{\|\}\~\"; 107 "\w\x00\y\z\{\|\}\~\";
95 108
96 Expect.equals(128 - 32, asciiLiterals.length); 109 Expect.equals(128 - 32, asciiLiterals.length);
97 for (int i = 32; i < 128; i++) { 110 for (int i = 32; i < 128; i++) {
98 int code = asciiLiterals.codeUnitAt(i - 32); 111 int code = asciiLiterals.codeUnitAt(i - 32);
99 if (code != 0) { 112 if (code != 0) {
100 Expect.equals(i, code); 113 Expect.equals(i, code);
101 } 114 }
102 } 115 }
103 } 116 }
104 117
105
106 testQuotes() { 118 testQuotes() {
107 // The string [ "' ]. 119 // The string [ "' ].
108 String bothQuotes = ' "' "' "; 120 String bothQuotes = ' "' "' ";
109 Expect.equals(bothQuotes, " \"' "); 121 Expect.equals(bothQuotes, " \"' ");
110 Expect.equals(bothQuotes, ' "\' '); 122 Expect.equals(bothQuotes, ' "\' ');
111 Expect.equals(bothQuotes, """ "' """); 123 Expect.equals(bothQuotes, """ "' """);
112 Expect.equals(bothQuotes, ''' "' '''); 124 Expect.equals(bothQuotes, ''' "' ''');
113 Expect.equals(bothQuotes, r""" "' """); 125 Expect.equals(bothQuotes, r""" "' """);
114 Expect.equals(bothQuotes, r''' "' '''); 126 Expect.equals(bothQuotes, r''' "' ''');
115 } 127 }
116 128
117
118 testRawStrings() { 129 testRawStrings() {
119 String raw1 = r'\x00'; 130 String raw1 = r'\x00';
120 Expect.equals(4, raw1.length); 131 Expect.equals(4, raw1.length);
121 Expect.equals(0x5c, raw1.codeUnitAt(0)); 132 Expect.equals(0x5c, raw1.codeUnitAt(0));
122 } 133 }
123 134
124 main() { 135 main() {
125 // Test \x??. 136 // Test \x??.
126 testXEscapes(); 137 testXEscapes();
127 // Test \u???? and \u{?+}. 138 // Test \u???? and \u{?+}.
128 testUEscapes(); 139 testUEscapes();
129 // Test \b, \f, \n, \r, \t, \v. 140 // Test \b, \f, \n, \r, \t, \v.
130 testSingleCharacterEscapes(); 141 testSingleCharacterEscapes();
131 // Test all other single character (identity) escaeps. 142 // Test all other single character (identity) escaeps.
132 testIdentityEscapes(); 143 testIdentityEscapes();
133 // Test that quotes are handled correctly. 144 // Test that quotes are handled correctly.
134 testQuotes(); 145 testQuotes();
135 // Test that raw strings are raw. 146 // Test that raw strings are raw.
136 testRawStrings(); 147 testRawStrings();
137 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698