| Index: runtime/vm/scanner_test.cc
|
| diff --git a/runtime/vm/scanner_test.cc b/runtime/vm/scanner_test.cc
|
| index f934c540583e68aed1262b20ca6ad98b6e626818..38ffc86d963f8bca5c73145edd31b47462edbcae 100644
|
| --- a/runtime/vm/scanner_test.cc
|
| +++ b/runtime/vm/scanner_test.cc
|
| @@ -2,18 +2,16 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| +#include "vm/scanner.h"
|
| #include "platform/assert.h"
|
| #include "vm/os.h"
|
| -#include "vm/scanner.h"
|
| #include "vm/token.h"
|
| #include "vm/unit_test.h"
|
|
|
| namespace dart {
|
|
|
| -
|
| typedef ZoneGrowableArray<Scanner::TokenDescriptor> GrowableTokenStream;
|
|
|
| -
|
| static void LogTokenDesc(Scanner::TokenDescriptor token) {
|
| OS::Print("pos %2d:%d-%d token %s ", token.position.line,
|
| token.position.column, token.position.column,
|
| @@ -24,7 +22,6 @@ static void LogTokenDesc(Scanner::TokenDescriptor token) {
|
| OS::Print("\n");
|
| }
|
|
|
| -
|
| static void LogTokenStream(const GrowableTokenStream& token_stream) {
|
| int token_index = 0;
|
| EXPECT_GT(token_stream.length(), 0);
|
| @@ -37,7 +34,6 @@ static void LogTokenStream(const GrowableTokenStream& token_stream) {
|
| EXPECT_EQ(token_stream.Last().kind, Token::kEOS);
|
| }
|
|
|
| -
|
| static void CheckKind(const GrowableTokenStream& token_stream,
|
| int index,
|
| Token::Kind kind) {
|
| @@ -48,7 +44,6 @@ static void CheckKind(const GrowableTokenStream& token_stream,
|
| EXPECT_EQ(kind, token_stream[index].kind);
|
| }
|
|
|
| -
|
| static void CheckLiteral(const GrowableTokenStream& token_stream,
|
| int index,
|
| const char* literal) {
|
| @@ -61,7 +56,6 @@ static void CheckLiteral(const GrowableTokenStream& token_stream,
|
| }
|
| }
|
|
|
| -
|
| static void CheckIdent(const GrowableTokenStream& token_stream,
|
| int index,
|
| const char* literal) {
|
| @@ -69,7 +63,6 @@ static void CheckIdent(const GrowableTokenStream& token_stream,
|
| CheckLiteral(token_stream, index, literal);
|
| }
|
|
|
| -
|
| static void CheckInteger(const GrowableTokenStream& token_stream,
|
| int index,
|
| const char* literal) {
|
| @@ -77,7 +70,6 @@ static void CheckInteger(const GrowableTokenStream& token_stream,
|
| CheckLiteral(token_stream, index, literal);
|
| }
|
|
|
| -
|
| static void CheckLineNumber(const GrowableTokenStream& token_stream,
|
| int index,
|
| int line_number) {
|
| @@ -87,7 +79,6 @@ static void CheckLineNumber(const GrowableTokenStream& token_stream,
|
| }
|
| }
|
|
|
| -
|
| static void CheckNumTokens(const GrowableTokenStream& token_stream, int index) {
|
| if (token_stream.length() != index) {
|
| OS::PrintErr("Expected %d tokens but got only %" Pd ".\n", index,
|
| @@ -95,7 +86,6 @@ static void CheckNumTokens(const GrowableTokenStream& token_stream, int index) {
|
| }
|
| }
|
|
|
| -
|
| class Collector : public Scanner::TokenCollector {
|
| public:
|
| explicit Collector(GrowableTokenStream* ts) : ts_(ts) {}
|
| @@ -109,7 +99,6 @@ class Collector : public Scanner::TokenCollector {
|
| GrowableTokenStream* ts_;
|
| };
|
|
|
| -
|
| static const GrowableTokenStream& Scan(const char* source) {
|
| OS::Print("\nScanning: <%s>\n", source);
|
|
|
| @@ -123,7 +112,6 @@ static const GrowableTokenStream& Scan(const char* source) {
|
| return *tokens;
|
| }
|
|
|
| -
|
| static void BoringTest() {
|
| const GrowableTokenStream& tokens = Scan("x = iffy++;");
|
|
|
| @@ -135,7 +123,6 @@ static void BoringTest() {
|
| CheckKind(tokens, 4, Token::kSEMICOLON);
|
| }
|
|
|
| -
|
| static void CommentTest() {
|
| const GrowableTokenStream& tokens = Scan(
|
| "Foo( /*block \n"
|
| @@ -151,7 +138,6 @@ static void CommentTest() {
|
| CheckLineNumber(tokens, 4, 2);
|
| }
|
|
|
| -
|
| static void GreedIsGood() {
|
| // means i++ + j
|
| const GrowableTokenStream& tokens = Scan("x=i+++j");
|
| @@ -165,7 +151,6 @@ static void GreedIsGood() {
|
| CheckIdent(tokens, 5, "j");
|
| }
|
|
|
| -
|
| static void StringEscapes() {
|
| // sss = "\" \\ \n\r\t \'"
|
| const GrowableTokenStream& tokens =
|
| @@ -189,7 +174,6 @@ static void StringEscapes() {
|
| EXPECT_EQ('\'', litchars[8]);
|
| }
|
|
|
| -
|
| static void InvalidStringEscapes() {
|
| const GrowableTokenStream& out_of_range_low = Scan("\"\\u{110000}\"");
|
| EXPECT_EQ(2, out_of_range_low.length());
|
| @@ -204,7 +188,6 @@ static void InvalidStringEscapes() {
|
| CheckKind(out_of_range_high, 1, Token::kEOS);
|
| }
|
|
|
| -
|
| static void RawString() {
|
| // rs = @"\' \\"
|
| const GrowableTokenStream& tokens = Scan("rs = r\"\\\' \\\\\"");
|
| @@ -225,7 +208,6 @@ static void RawString() {
|
| EXPECT_EQ('\\', litchars[4]);
|
| }
|
|
|
| -
|
| static void MultilineString() {
|
| // |mls = '''
|
| // |1' x
|
| @@ -253,7 +235,6 @@ static void MultilineString() {
|
| EXPECT_EQ('2', litchars[5]);
|
| }
|
|
|
| -
|
| static void EmptyString() {
|
| // es = "";
|
| const GrowableTokenStream& tokens = Scan("es = \"\";");
|
| @@ -280,7 +261,6 @@ static void EmptyMultilineString() {
|
| EXPECT_EQ(0, (tokens)[2].literal->Length());
|
| }
|
|
|
| -
|
| static void NumberLiteral() {
|
| const GrowableTokenStream& tokens = Scan("5 0x5d 0.3 0.33 1E+12 .42 +5");
|
|
|
| @@ -295,7 +275,6 @@ static void NumberLiteral() {
|
| CheckKind(tokens, 8, Token::kEOS);
|
| }
|
|
|
| -
|
| static void ScanLargeText() {
|
| const char* dart_source =
|
| "// This source is not meant to be valid Dart code. The text is used to"
|
| @@ -359,7 +338,6 @@ static void ScanLargeText() {
|
| Scan(dart_source);
|
| }
|
|
|
| -
|
| void InvalidText() {
|
| const GrowableTokenStream& tokens = Scan("\\");
|
|
|
| @@ -368,7 +346,6 @@ void InvalidText() {
|
| CheckKind(tokens, 1, Token::kEOS);
|
| }
|
|
|
| -
|
| void NewlinesTest() {
|
| const char* source =
|
| "var es = /* a\n"
|
| @@ -401,7 +378,6 @@ void NewlinesTest() {
|
| EXPECT_EQ('\n', litchars[3]);
|
| }
|
|
|
| -
|
| TEST_CASE(Scanner_Test) {
|
| ScanLargeText();
|
|
|
|
|