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

Side by Side Diff: runtime/vm/scanner_test.cc

Issue 2304923002: Allow surrogates in string literals. (Closed)
Patch Set: Fixed another 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 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/os.h" 6 #include "vm/os.h"
7 #include "vm/scanner.h" 7 #include "vm/scanner.h"
8 #include "vm/token.h" 8 #include "vm/token.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 EXPECT_EQ(' ', litchars[1]); 185 EXPECT_EQ(' ', litchars[1]);
186 EXPECT_EQ('\\', litchars[2]); 186 EXPECT_EQ('\\', litchars[2]);
187 EXPECT_EQ('\n', litchars[4]); 187 EXPECT_EQ('\n', litchars[4]);
188 EXPECT_EQ('\r', litchars[5]); 188 EXPECT_EQ('\r', litchars[5]);
189 EXPECT_EQ('\t', litchars[6]); 189 EXPECT_EQ('\t', litchars[6]);
190 EXPECT_EQ('\'', litchars[8]); 190 EXPECT_EQ('\'', litchars[8]);
191 } 191 }
192 192
193 193
194 static void InvalidStringEscapes() { 194 static void InvalidStringEscapes() {
195 const GrowableTokenStream& high_start_4 =
196 Scan("\"\\uD800\"");
197 EXPECT_EQ(2, high_start_4.length());
198 CheckKind(high_start_4, 0, Token::kERROR);
199 EXPECT(high_start_4[0].literal->Equals("invalid code point"));
200 CheckKind(high_start_4, 1, Token::kEOS);
201
202 const GrowableTokenStream& high_start_seq =
203 Scan("\"\\u{D800}\"");
204 EXPECT_EQ(2, high_start_seq.length());
205 CheckKind(high_start_seq, 0, Token::kERROR);
206 EXPECT(high_start_seq[0].literal->Equals("invalid code point"));
207 CheckKind(high_start_seq, 1, Token::kEOS);
208
209 const GrowableTokenStream& high_end_4 =
210 Scan("\"\\uDBFF\"");
211 EXPECT_EQ(2, high_end_4.length());
212 CheckKind(high_end_4, 0, Token::kERROR);
213 EXPECT(high_end_4[0].literal->Equals("invalid code point"));
214 CheckKind(high_end_4, 1, Token::kEOS);
215
216 const GrowableTokenStream& high_end_seq =
217 Scan("\"\\u{DBFF}\"");
218 EXPECT_EQ(2, high_end_seq.length());
219 CheckKind(high_end_seq, 0, Token::kERROR);
220 EXPECT(high_end_seq[0].literal->Equals("invalid code point"));
221 CheckKind(high_end_seq, 1, Token::kEOS);
222
223 const GrowableTokenStream& low_start_4 =
224 Scan("\"\\uDC00\"");
225 EXPECT_EQ(2, low_start_4.length());
226 CheckKind(low_start_4, 0, Token::kERROR);
227 EXPECT(low_start_4[0].literal->Equals("invalid code point"));
228 CheckKind(low_start_4, 1, Token::kEOS);
229
230 const GrowableTokenStream& low_start_seq =
231 Scan("\"\\u{DC00}\"");
232 EXPECT_EQ(2, low_start_seq.length());
233 CheckKind(low_start_seq, 0, Token::kERROR);
234 EXPECT(low_start_seq[0].literal->Equals("invalid code point"));
235 CheckKind(low_start_seq, 1, Token::kEOS);
236
237 const GrowableTokenStream& low_end_4 =
238 Scan("\"\\uDFFF\"");
239 EXPECT_EQ(2, low_end_4.length());
240 CheckKind(low_end_4, 0, Token::kERROR);
241 EXPECT(low_end_4[0].literal->Equals("invalid code point"));
242 CheckKind(low_end_4, 1, Token::kEOS);
243
244 const GrowableTokenStream& low_end_seq =
245 Scan("\"\\u{DFFF}\"");
246 EXPECT_EQ(2, low_end_seq.length());
247 CheckKind(low_end_seq, 0, Token::kERROR);
248 EXPECT(low_end_seq[0].literal->Equals("invalid code point"));
249 CheckKind(low_end_seq, 1, Token::kEOS);
250
251 const GrowableTokenStream& out_of_range_low = 195 const GrowableTokenStream& out_of_range_low =
252 Scan("\"\\u{110000}\""); 196 Scan("\"\\u{110000}\"");
253 EXPECT_EQ(2, out_of_range_low.length()); 197 EXPECT_EQ(2, out_of_range_low.length());
254 CheckKind(out_of_range_low, 0, Token::kERROR); 198 CheckKind(out_of_range_low, 0, Token::kERROR);
255 EXPECT(out_of_range_low[0].literal->Equals("invalid code point")); 199 EXPECT(out_of_range_low[0].literal->Equals("invalid code point"));
256 CheckKind(out_of_range_low, 1, Token::kEOS); 200 CheckKind(out_of_range_low, 1, Token::kEOS);
257 201
258 const GrowableTokenStream& out_of_range_high = 202 const GrowableTokenStream& out_of_range_high =
259 Scan("\"\\u{FFFFFF}\""); 203 Scan("\"\\u{FFFFFF}\"");
260 EXPECT_EQ(2, out_of_range_high.length()); 204 EXPECT_EQ(2, out_of_range_high.length());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 RawString(); 418 RawString();
475 MultilineString(); 419 MultilineString();
476 EmptyString(); 420 EmptyString();
477 EmptyMultilineString(); 421 EmptyMultilineString();
478 NumberLiteral(); 422 NumberLiteral();
479 InvalidText(); 423 InvalidText();
480 NewlinesTest(); 424 NewlinesTest();
481 } 425 }
482 426
483 } // namespace dart 427 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698