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

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

Issue 24359005: Make Script::GetTokenLocation() and Script::TokenRangeAtLine() use token streams where possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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') | no next file » | 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 void InvalidText() { 403 void InvalidText() {
404 const Scanner::GrowableTokenStream& tokens = 404 const Scanner::GrowableTokenStream& tokens =
405 Scan("\\"); 405 Scan("\\");
406 406
407 EXPECT_EQ(2, tokens.length()); 407 EXPECT_EQ(2, tokens.length());
408 CheckKind(tokens, 0, Token::kERROR); 408 CheckKind(tokens, 0, Token::kERROR);
409 CheckKind(tokens, 1, Token::kEOS); 409 CheckKind(tokens, 1, Token::kEOS);
410 } 410 }
411 411
412 412
413 void FindLineTest() {
414 const char* source =
415 "/*1*/ \n"
416 "/*2*/ class A {\n"
417 "/*3*/ void foo() { }\n"
418 "/*4*/ }\n";
419
420 Scanner scanner(String::Handle(String::New(source)),
421 String::Handle(String::New("")));
422
423 intptr_t first_token_index, last_token_index;
424 scanner.TokenRangeAtLine(3, &first_token_index, &last_token_index);
425 EXPECT_EQ(3, first_token_index);
426 EXPECT_EQ(8, last_token_index);
427 scanner.TokenRangeAtLine(100, &first_token_index, &last_token_index);
428 EXPECT(first_token_index < 0);
429 scanner.TokenRangeAtLine(1, &first_token_index, &last_token_index);
430 EXPECT_EQ(0, first_token_index);
431 EXPECT(last_token_index < 0);
432 }
433
434
435 void NewlinesTest() { 413 void NewlinesTest() {
436 const char* source = 414 const char* source =
437 "var es = /* a\n" 415 "var es = /* a\n"
438 " b\n" 416 " b\n"
439 " */ \"\"\"\n" 417 " */ \"\"\"\n"
440 "c\n" 418 "c\n"
441 "d\n" 419 "d\n"
442 "\"\"\";"; 420 "\"\"\";";
443 421
444 const Scanner::GrowableTokenStream& tokens = Scan(source); 422 const Scanner::GrowableTokenStream& tokens = Scan(source);
(...skipping 27 matching lines...) Expand all
472 CommentTest(); 450 CommentTest();
473 GreedIsGood(); 451 GreedIsGood();
474 StringEscapes(); 452 StringEscapes();
475 InvalidStringEscapes(); 453 InvalidStringEscapes();
476 RawString(); 454 RawString();
477 MultilineString(); 455 MultilineString();
478 EmptyString(); 456 EmptyString();
479 EmptyMultilineString(); 457 EmptyMultilineString();
480 NumberLiteral(); 458 NumberLiteral();
481 InvalidText(); 459 InvalidText();
482 FindLineTest();
483 NewlinesTest(); 460 NewlinesTest();
484 } 461 }
485 462
486 } // namespace dart 463 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698