| OLD | NEW |
| 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 void FindLineTest() { | 410 void FindLineTest() { |
| 411 const char* source = | 411 const char* source = |
| 412 "/*1*/ \n" | 412 "/*1*/ \n" |
| 413 "/*2*/ class A {\n" | 413 "/*2*/ class A {\n" |
| 414 "/*3*/ void foo() { }\n" | 414 "/*3*/ void foo() { }\n" |
| 415 "/*4*/ }\n"; | 415 "/*4*/ }\n"; |
| 416 | 416 |
| 417 Scanner scanner(String::Handle(String::New(source)), | 417 Scanner scanner(String::Handle(String::New(source)), |
| 418 String::Handle(String::New(""))); | 418 String::Handle(String::New(""))); |
| 419 | 419 |
| 420 intptr_t token_index = scanner.TokenIndexAtLine(3); | 420 intptr_t first_token_index, last_token_index; |
| 421 EXPECT_EQ(3, token_index); | 421 scanner.TokenRangeAtLine(3, &first_token_index, &last_token_index); |
| 422 token_index = scanner.TokenIndexAtLine(100); | 422 EXPECT_EQ(3, first_token_index); |
| 423 EXPECT(token_index < 0); | 423 EXPECT_EQ(8, last_token_index); |
| 424 scanner.TokenRangeAtLine(100, &first_token_index, &last_token_index); |
| 425 EXPECT(first_token_index < 0); |
| 426 scanner.TokenRangeAtLine(1, &first_token_index, &last_token_index); |
| 427 EXPECT_EQ(0, first_token_index); |
| 428 EXPECT(last_token_index < 0); |
| 424 } | 429 } |
| 425 | 430 |
| 426 | 431 |
| 427 TEST_CASE(Scanner_Test) { | 432 TEST_CASE(Scanner_Test) { |
| 428 ScanLargeText(); | 433 ScanLargeText(); |
| 429 | 434 |
| 430 BoringTest(); | 435 BoringTest(); |
| 431 CommentTest(); | 436 CommentTest(); |
| 432 GreedIsGood(); | 437 GreedIsGood(); |
| 433 StringEscapes(); | 438 StringEscapes(); |
| 434 InvalidStringEscapes(); | 439 InvalidStringEscapes(); |
| 435 RawString(); | 440 RawString(); |
| 436 MultilineString(); | 441 MultilineString(); |
| 437 EmptyString(); | 442 EmptyString(); |
| 438 EmptyMultilineString(); | 443 EmptyMultilineString(); |
| 439 NumberLiteral(); | 444 NumberLiteral(); |
| 440 InvalidText(); | 445 InvalidText(); |
| 441 FindLineTest(); | 446 FindLineTest(); |
| 442 } | 447 } |
| 443 | 448 |
| 444 } // namespace dart | 449 } // namespace dart |
| OLD | NEW |