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

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

Issue 9264051: Fix for bug 1229: Unary operator plus is not allowed ... except for literals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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
« no previous file with comments | « runtime/vm/scanner.cc ('k') | runtime/vm/token.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24 matching lines...) Expand all
35 } 35 }
36 36
37 37
38 void CheckKind(const Scanner::GrowableTokenStream &token_stream, 38 void CheckKind(const Scanner::GrowableTokenStream &token_stream,
39 int index, 39 int index,
40 Token::Kind kind) { 40 Token::Kind kind) {
41 if (token_stream[index].kind != kind) { 41 if (token_stream[index].kind != kind) {
42 OS::PrintErr("Token %d: expected kind %s but got %s\n", index, 42 OS::PrintErr("Token %d: expected kind %s but got %s\n", index,
43 Token::Name(token_stream[index].kind), Token::Name(kind)); 43 Token::Name(token_stream[index].kind), Token::Name(kind));
44 } 44 }
45 EXPECT_EQ(kind, token_stream[index].kind);
45 } 46 }
46 47
47 48
48 void CheckLiteral(const Scanner::GrowableTokenStream& token_stream, 49 void CheckLiteral(const Scanner::GrowableTokenStream& token_stream,
49 int index, 50 int index,
50 const char* literal) { 51 const char* literal) {
51 if (token_stream[index].literal == NULL) { 52 if (token_stream[index].literal == NULL) {
52 OS::PrintErr("Token %d: expected literal \"%s\" but got nothing\n", 53 OS::PrintErr("Token %d: expected literal \"%s\" but got nothing\n",
53 index, literal); 54 index, literal);
54 } else if (strcmp(literal, token_stream[index].literal->ToCString())) { 55 } else if (strcmp(literal, token_stream[index].literal->ToCString())) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 CheckKind(tokens, 1, Token::kASSIGN); 239 CheckKind(tokens, 1, Token::kASSIGN);
239 CheckKind(tokens, 2, Token::kSTRING); 240 CheckKind(tokens, 2, Token::kSTRING);
240 CheckKind(tokens, 3, Token::kSEMICOLON); 241 CheckKind(tokens, 3, Token::kSEMICOLON);
241 CheckKind(tokens, 4, Token::kEOS); 242 CheckKind(tokens, 4, Token::kEOS);
242 EXPECT_EQ(0, (tokens)[2].literal->Length()); 243 EXPECT_EQ(0, (tokens)[2].literal->Length());
243 } 244 }
244 245
245 246
246 void NumberLiteral() { 247 void NumberLiteral() {
247 const Scanner::GrowableTokenStream& tokens = 248 const Scanner::GrowableTokenStream& tokens =
248 Scan("5 0x5d 0.3 0.33 1E+12 .42"); 249 Scan("5 0x5d 0.3 0.33 1E+12 .42 +5");
249 250
250 CheckKind(tokens, 0, Token::kINTEGER); 251 CheckKind(tokens, 0, Token::kINTEGER);
251 CheckKind(tokens, 1, Token::kINTEGER); 252 CheckKind(tokens, 1, Token::kINTEGER);
252 CheckKind(tokens, 2, Token::kDOUBLE); 253 CheckKind(tokens, 2, Token::kDOUBLE);
253 CheckKind(tokens, 3, Token::kDOUBLE); 254 CheckKind(tokens, 3, Token::kDOUBLE);
254 CheckKind(tokens, 4, Token::kDOUBLE); 255 CheckKind(tokens, 4, Token::kDOUBLE);
255 CheckKind(tokens, 5, Token::kDOUBLE); 256 CheckKind(tokens, 5, Token::kDOUBLE);
256 CheckKind(tokens, 6, Token::kEOS); 257 CheckKind(tokens, 6, Token::kTIGHTADD);
258 CheckKind(tokens, 7, Token::kINTEGER);
259 CheckKind(tokens, 8, Token::kEOS);
257 } 260 }
258 261
259 262
260 void ScanLargeText() { 263 void ScanLargeText() {
261 const char* dart_source = 264 const char* dart_source =
262 "// This source is not meant to be valid Dart code. The text is used to" 265 "// This source is not meant to be valid Dart code. The text is used to"
263 "// test the Dart scanner." 266 "// test the Dart scanner."
264 "" 267 ""
265 "// Cartesian point implemetation." 268 "// Cartesian point implemetation."
266 "class Point {" 269 "class Point {"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 RawString(); 361 RawString();
359 MultilineString(); 362 MultilineString();
360 EmptyString(); 363 EmptyString();
361 EmptyMultilineString(); 364 EmptyMultilineString();
362 NumberLiteral(); 365 NumberLiteral();
363 InvalidText(); 366 InvalidText();
364 FindLineTest(); 367 FindLineTest();
365 } 368 }
366 369
367 } // namespace dart 370 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/scanner.cc ('k') | runtime/vm/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698