| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine.scanner_test; | 3 library engine.scanner_test; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
| 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; | 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; |
| 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
| 8 import 'package:analyzer_experimental/src/generated/source.dart'; | 8 import 'package:analyzer_experimental/src/generated/source.dart'; |
| 9 import 'package:analyzer_experimental/src/generated/error.dart'; | 9 import 'package:analyzer_experimental/src/generated/error.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
| (...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 assertKeywordToken("void"); | 1872 assertKeywordToken("void"); |
| 1873 } | 1873 } |
| 1874 void test_keyword_while() { | 1874 void test_keyword_while() { |
| 1875 assertKeywordToken("while"); | 1875 assertKeywordToken("while"); |
| 1876 } | 1876 } |
| 1877 void test_keyword_with() { | 1877 void test_keyword_with() { |
| 1878 assertKeywordToken("with"); | 1878 assertKeywordToken("with"); |
| 1879 } | 1879 } |
| 1880 void test_lineInfo_multilineComment() { | 1880 void test_lineInfo_multilineComment() { |
| 1881 String source = "/*\r *\r */"; | 1881 String source = "/*\r *\r */"; |
| 1882 assertLineInfo(source, [new AbstractScannerTest_ExpectedLocation(0, 1, 1), n
ew AbstractScannerTest_ExpectedLocation(4, 2, 2), new AbstractScannerTest_Expect
edLocation(source.length - 1, 3, 3)]); | 1882 assertLineInfo(source, [ |
| 1883 new AbstractScannerTest_ExpectedLocation(0, 1, 1), |
| 1884 new AbstractScannerTest_ExpectedLocation(4, 2, 2), |
| 1885 new AbstractScannerTest_ExpectedLocation(source.length - 1, 3, 3)]); |
| 1883 } | 1886 } |
| 1884 void test_lineInfo_simpleClass() { | 1887 void test_lineInfo_simpleClass() { |
| 1885 String source = "class Test {\r\n String s = '...';\r\n int get x => s
.MISSING_GETTER;\r\n}"; | 1888 String source = "class Test {\r\n String s = '...';\r\n int get x => s
.MISSING_GETTER;\r\n}"; |
| 1886 assertLineInfo(source, [new AbstractScannerTest_ExpectedLocation(0, 1, 1), n
ew AbstractScannerTest_ExpectedLocation(source.indexOf("MISSING_GETTER"), 3, 20)
, new AbstractScannerTest_ExpectedLocation(source.length - 1, 4, 1)]); | 1889 assertLineInfo(source, [ |
| 1890 new AbstractScannerTest_ExpectedLocation(0, 1, 1), |
| 1891 new AbstractScannerTest_ExpectedLocation(source.indexOf("MISSING_GETTER"
), 3, 20), |
| 1892 new AbstractScannerTest_ExpectedLocation(source.length - 1, 4, 1)]); |
| 1887 } | 1893 } |
| 1888 void test_lineInfo_slashN() { | 1894 void test_lineInfo_slashN() { |
| 1889 String source = "class Test {\n}"; | 1895 String source = "class Test {\n}"; |
| 1890 assertLineInfo(source, [new AbstractScannerTest_ExpectedLocation(0, 1, 1), n
ew AbstractScannerTest_ExpectedLocation(source.indexOf("}"), 2, 1)]); | 1896 assertLineInfo(source, [ |
| 1897 new AbstractScannerTest_ExpectedLocation(0, 1, 1), |
| 1898 new AbstractScannerTest_ExpectedLocation(source.indexOf("}"), 2, 1)]); |
| 1891 } | 1899 } |
| 1892 void test_lt() { | 1900 void test_lt() { |
| 1893 assertToken(TokenType.LT, "<"); | 1901 assertToken(TokenType.LT, "<"); |
| 1894 } | 1902 } |
| 1895 void test_lt_eq() { | 1903 void test_lt_eq() { |
| 1896 assertToken(TokenType.LT_EQ, "<="); | 1904 assertToken(TokenType.LT_EQ, "<="); |
| 1897 } | 1905 } |
| 1898 void test_lt_lt() { | 1906 void test_lt_lt() { |
| 1899 assertToken(TokenType.LT_LT, "<<"); | 1907 assertToken(TokenType.LT_LT, "<<"); |
| 1900 } | 1908 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1931 void test_period() { | 1939 void test_period() { |
| 1932 assertToken(TokenType.PERIOD, "."); | 1940 assertToken(TokenType.PERIOD, "."); |
| 1933 } | 1941 } |
| 1934 void test_period_period() { | 1942 void test_period_period() { |
| 1935 assertToken(TokenType.PERIOD_PERIOD, ".."); | 1943 assertToken(TokenType.PERIOD_PERIOD, ".."); |
| 1936 } | 1944 } |
| 1937 void test_period_period_period() { | 1945 void test_period_period_period() { |
| 1938 assertToken(TokenType.PERIOD_PERIOD_PERIOD, "..."); | 1946 assertToken(TokenType.PERIOD_PERIOD_PERIOD, "..."); |
| 1939 } | 1947 } |
| 1940 void test_periodAfterNumberNotIncluded_identifier() { | 1948 void test_periodAfterNumberNotIncluded_identifier() { |
| 1941 assertTokens("42.isEven()", [new StringToken(TokenType.INT, "42", 0), new To
ken(TokenType.PERIOD, 2), new StringToken(TokenType.IDENTIFIER, "isEven", 3), ne
w Token(TokenType.OPEN_PAREN, 9), new Token(TokenType.CLOSE_PAREN, 10)]); | 1949 assertTokens("42.isEven()", [ |
| 1950 new StringToken(TokenType.INT, "42", 0), |
| 1951 new Token(TokenType.PERIOD, 2), |
| 1952 new StringToken(TokenType.IDENTIFIER, "isEven", 3), |
| 1953 new Token(TokenType.OPEN_PAREN, 9), |
| 1954 new Token(TokenType.CLOSE_PAREN, 10)]); |
| 1942 } | 1955 } |
| 1943 void test_periodAfterNumberNotIncluded_period() { | 1956 void test_periodAfterNumberNotIncluded_period() { |
| 1944 assertTokens("42..isEven()", [new StringToken(TokenType.INT, "42", 0), new T
oken(TokenType.PERIOD_PERIOD, 2), new StringToken(TokenType.IDENTIFIER, "isEven"
, 4), new Token(TokenType.OPEN_PAREN, 10), new Token(TokenType.CLOSE_PAREN, 11)]
); | 1957 assertTokens("42..isEven()", [ |
| 1958 new StringToken(TokenType.INT, "42", 0), |
| 1959 new Token(TokenType.PERIOD_PERIOD, 2), |
| 1960 new StringToken(TokenType.IDENTIFIER, "isEven", 4), |
| 1961 new Token(TokenType.OPEN_PAREN, 10), |
| 1962 new Token(TokenType.CLOSE_PAREN, 11)]); |
| 1945 } | 1963 } |
| 1946 void test_plus() { | 1964 void test_plus() { |
| 1947 assertToken(TokenType.PLUS, "+"); | 1965 assertToken(TokenType.PLUS, "+"); |
| 1948 } | 1966 } |
| 1949 void test_plus_eq() { | 1967 void test_plus_eq() { |
| 1950 assertToken(TokenType.PLUS_EQ, "+="); | 1968 assertToken(TokenType.PLUS_EQ, "+="); |
| 1951 } | 1969 } |
| 1952 void test_plus_plus() { | 1970 void test_plus_plus() { |
| 1953 assertToken(TokenType.PLUS_PLUS, "++"); | 1971 assertToken(TokenType.PLUS_PLUS, "++"); |
| 1954 } | 1972 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1985 JUnitTestCase.assertEquals(token, previous.next); | 2003 JUnitTestCase.assertEquals(token, previous.next); |
| 1986 JUnitTestCase.assertEquals(previous, previous.previous); | 2004 JUnitTestCase.assertEquals(previous, previous.previous); |
| 1987 Token next = token.next; | 2005 Token next = token.next; |
| 1988 JUnitTestCase.assertEquals(next, next.next); | 2006 JUnitTestCase.assertEquals(next, next.next); |
| 1989 JUnitTestCase.assertEquals(token, next.previous); | 2007 JUnitTestCase.assertEquals(token, next.previous); |
| 1990 } | 2008 } |
| 1991 void test_string_multi_double() { | 2009 void test_string_multi_double() { |
| 1992 assertToken(TokenType.STRING, "\"\"\"multi-line\nstring\"\"\""); | 2010 assertToken(TokenType.STRING, "\"\"\"multi-line\nstring\"\"\""); |
| 1993 } | 2011 } |
| 1994 void test_string_multi_interpolation_block() { | 2012 void test_string_multi_interpolation_block() { |
| 1995 assertTokens("\"Hello \${name}!\"", [new StringToken(TokenType.STRING, "\"He
llo ", 0), new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 7),
new StringToken(TokenType.IDENTIFIER, "name", 9), new Token(TokenType.CLOSE_CUR
LY_BRACKET, 13), new StringToken(TokenType.STRING, "!\"", 14)]); | 2013 assertTokens("\"Hello \${name}!\"", [ |
| 2014 new StringToken(TokenType.STRING, "\"Hello ", 0), |
| 2015 new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 7), |
| 2016 new StringToken(TokenType.IDENTIFIER, "name", 9), |
| 2017 new Token(TokenType.CLOSE_CURLY_BRACKET, 13), |
| 2018 new StringToken(TokenType.STRING, "!\"", 14)]); |
| 1996 } | 2019 } |
| 1997 void test_string_multi_interpolation_identifier() { | 2020 void test_string_multi_interpolation_identifier() { |
| 1998 assertTokens("\"Hello \$name!\"", [new StringToken(TokenType.STRING, "\"Hell
o ", 0), new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 7), ne
w StringToken(TokenType.IDENTIFIER, "name", 8), new StringToken(TokenType.STRING
, "!\"", 12)]); | 2021 assertTokens("\"Hello \$name!\"", [ |
| 2022 new StringToken(TokenType.STRING, "\"Hello ", 0), |
| 2023 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 7), |
| 2024 new StringToken(TokenType.IDENTIFIER, "name", 8), |
| 2025 new StringToken(TokenType.STRING, "!\"", 12)]); |
| 1999 } | 2026 } |
| 2000 void test_string_multi_single() { | 2027 void test_string_multi_single() { |
| 2001 assertToken(TokenType.STRING, "'''string'''"); | 2028 assertToken(TokenType.STRING, "'''string'''"); |
| 2002 } | 2029 } |
| 2003 void test_string_multi_slashEnter() { | 2030 void test_string_multi_slashEnter() { |
| 2004 assertError(ScannerErrorCode.CHARACTER_EXPECTED_AFTER_SLASH, 0, "'''\\\n'''"
); | 2031 assertError(ScannerErrorCode.CHARACTER_EXPECTED_AFTER_SLASH, 0, "'''\\\n'''"
); |
| 2005 } | 2032 } |
| 2006 void test_string_multi_unterminated() { | 2033 void test_string_multi_unterminated() { |
| 2007 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 8, "'''string"); | 2034 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 8, "'''string"); |
| 2008 } | 2035 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2027 void test_string_raw_simple_unterminated_eol() { | 2054 void test_string_raw_simple_unterminated_eol() { |
| 2028 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 8, "r'string\n"); | 2055 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 8, "r'string\n"); |
| 2029 } | 2056 } |
| 2030 void test_string_simple_double() { | 2057 void test_string_simple_double() { |
| 2031 assertToken(TokenType.STRING, "\"string\""); | 2058 assertToken(TokenType.STRING, "\"string\""); |
| 2032 } | 2059 } |
| 2033 void test_string_simple_escapedDollar() { | 2060 void test_string_simple_escapedDollar() { |
| 2034 assertToken(TokenType.STRING, "'a\\\$b'"); | 2061 assertToken(TokenType.STRING, "'a\\\$b'"); |
| 2035 } | 2062 } |
| 2036 void test_string_simple_interpolation_adjacentIdentifiers() { | 2063 void test_string_simple_interpolation_adjacentIdentifiers() { |
| 2037 assertTokens("'\$a\$b'", [new StringToken(TokenType.STRING, "'", 0), new Str
ingToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), new StringToken(To
kenType.IDENTIFIER, "a", 2), new StringToken(TokenType.STRING, "", 3), new Strin
gToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 3), new StringToken(Toke
nType.IDENTIFIER, "b", 4), new StringToken(TokenType.STRING, "'", 5)]); | 2064 assertTokens("'\$a\$b'", [ |
| 2065 new StringToken(TokenType.STRING, "'", 0), |
| 2066 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), |
| 2067 new StringToken(TokenType.IDENTIFIER, "a", 2), |
| 2068 new StringToken(TokenType.STRING, "", 3), |
| 2069 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 3), |
| 2070 new StringToken(TokenType.IDENTIFIER, "b", 4), |
| 2071 new StringToken(TokenType.STRING, "'", 5)]); |
| 2038 } | 2072 } |
| 2039 void test_string_simple_interpolation_block() { | 2073 void test_string_simple_interpolation_block() { |
| 2040 assertTokens("'Hello \${name}!'", [new StringToken(TokenType.STRING, "'Hello
", 0), new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 7), ne
w StringToken(TokenType.IDENTIFIER, "name", 9), new Token(TokenType.CLOSE_CURLY_
BRACKET, 13), new StringToken(TokenType.STRING, "!'", 14)]); | 2074 assertTokens("'Hello \${name}!'", [ |
| 2075 new StringToken(TokenType.STRING, "'Hello ", 0), |
| 2076 new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 7), |
| 2077 new StringToken(TokenType.IDENTIFIER, "name", 9), |
| 2078 new Token(TokenType.CLOSE_CURLY_BRACKET, 13), |
| 2079 new StringToken(TokenType.STRING, "!'", 14)]); |
| 2041 } | 2080 } |
| 2042 void test_string_simple_interpolation_blockWithNestedMap() { | 2081 void test_string_simple_interpolation_blockWithNestedMap() { |
| 2043 assertTokens("'a \${f({'b' : 'c'})} d'", [new StringToken(TokenType.STRING,
"'a ", 0), new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 3),
new StringToken(TokenType.IDENTIFIER, "f", 5), new Token(TokenType.OPEN_PAREN,
6), new Token(TokenType.OPEN_CURLY_BRACKET, 7), new StringToken(TokenType.STRING
, "'b'", 8), new Token(TokenType.COLON, 12), new StringToken(TokenType.STRING, "
'c'", 14), new Token(TokenType.CLOSE_CURLY_BRACKET, 17), new Token(TokenType.CLO
SE_PAREN, 18), new Token(TokenType.CLOSE_CURLY_BRACKET, 19), new StringToken(Tok
enType.STRING, " d'", 20)]); | 2082 assertTokens("'a \${f({'b' : 'c'})} d'", [ |
| 2083 new StringToken(TokenType.STRING, "'a ", 0), |
| 2084 new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 3), |
| 2085 new StringToken(TokenType.IDENTIFIER, "f", 5), |
| 2086 new Token(TokenType.OPEN_PAREN, 6), |
| 2087 new Token(TokenType.OPEN_CURLY_BRACKET, 7), |
| 2088 new StringToken(TokenType.STRING, "'b'", 8), |
| 2089 new Token(TokenType.COLON, 12), |
| 2090 new StringToken(TokenType.STRING, "'c'", 14), |
| 2091 new Token(TokenType.CLOSE_CURLY_BRACKET, 17), |
| 2092 new Token(TokenType.CLOSE_PAREN, 18), |
| 2093 new Token(TokenType.CLOSE_CURLY_BRACKET, 19), |
| 2094 new StringToken(TokenType.STRING, " d'", 20)]); |
| 2044 } | 2095 } |
| 2045 void test_string_simple_interpolation_firstAndLast() { | 2096 void test_string_simple_interpolation_firstAndLast() { |
| 2046 assertTokens("'\$greeting \$name'", [new StringToken(TokenType.STRING, "'",
0), new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), new Str
ingToken(TokenType.IDENTIFIER, "greeting", 2), new StringToken(TokenType.STRING,
" ", 10), new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 11),
new StringToken(TokenType.IDENTIFIER, "name", 12), new StringToken(TokenType.ST
RING, "'", 16)]); | 2097 assertTokens("'\$greeting \$name'", [ |
| 2098 new StringToken(TokenType.STRING, "'", 0), |
| 2099 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), |
| 2100 new StringToken(TokenType.IDENTIFIER, "greeting", 2), |
| 2101 new StringToken(TokenType.STRING, " ", 10), |
| 2102 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 11), |
| 2103 new StringToken(TokenType.IDENTIFIER, "name", 12), |
| 2104 new StringToken(TokenType.STRING, "'", 16)]); |
| 2047 } | 2105 } |
| 2048 void test_string_simple_interpolation_identifier() { | 2106 void test_string_simple_interpolation_identifier() { |
| 2049 assertTokens("'Hello \$name!'", [new StringToken(TokenType.STRING, "'Hello "
, 0), new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 7), new S
tringToken(TokenType.IDENTIFIER, "name", 8), new StringToken(TokenType.STRING, "
!'", 12)]); | 2107 assertTokens("'Hello \$name!'", [ |
| 2108 new StringToken(TokenType.STRING, "'Hello ", 0), |
| 2109 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 7), |
| 2110 new StringToken(TokenType.IDENTIFIER, "name", 8), |
| 2111 new StringToken(TokenType.STRING, "!'", 12)]); |
| 2050 } | 2112 } |
| 2051 void test_string_simple_interpolation_missingIdentifier() { | 2113 void test_string_simple_interpolation_missingIdentifier() { |
| 2052 assertTokens("'\$x\$'", [new StringToken(TokenType.STRING, "'", 0), new Stri
ngToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), new StringToken(Tok
enType.IDENTIFIER, "x", 2), new StringToken(TokenType.STRING, "", 3), new String
Token(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 3), new StringToken(Token
Type.STRING, "'", 4)]); | 2114 assertTokens("'\$x\$'", [ |
| 2115 new StringToken(TokenType.STRING, "'", 0), |
| 2116 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), |
| 2117 new StringToken(TokenType.IDENTIFIER, "x", 2), |
| 2118 new StringToken(TokenType.STRING, "", 3), |
| 2119 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 3), |
| 2120 new StringToken(TokenType.STRING, "'", 4)]); |
| 2053 } | 2121 } |
| 2054 void test_string_simple_interpolation_nonIdentifier() { | 2122 void test_string_simple_interpolation_nonIdentifier() { |
| 2055 assertTokens("'\$1'", [new StringToken(TokenType.STRING, "'", 0), new String
Token(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), new StringToken(Token
Type.STRING, "1'", 2)]); | 2123 assertTokens("'\$1'", [ |
| 2124 new StringToken(TokenType.STRING, "'", 0), |
| 2125 new StringToken(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 1), |
| 2126 new StringToken(TokenType.STRING, "1'", 2)]); |
| 2056 } | 2127 } |
| 2057 void test_string_simple_single() { | 2128 void test_string_simple_single() { |
| 2058 assertToken(TokenType.STRING, "'string'"); | 2129 assertToken(TokenType.STRING, "'string'"); |
| 2059 } | 2130 } |
| 2060 void test_string_simple_unterminated_eof() { | 2131 void test_string_simple_unterminated_eof() { |
| 2061 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 6, "'string"); | 2132 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 6, "'string"); |
| 2062 } | 2133 } |
| 2063 void test_string_simple_unterminated_eol() { | 2134 void test_string_simple_unterminated_eol() { |
| 2064 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 7, "'string\r"); | 2135 assertError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 7, "'string\r"); |
| 2065 } | 2136 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2217 this._lineNumber = lineNumber; | 2288 this._lineNumber = lineNumber; |
| 2218 this._columnNumber = columnNumber; | 2289 this._columnNumber = columnNumber; |
| 2219 } | 2290 } |
| 2220 } | 2291 } |
| 2221 main() { | 2292 main() { |
| 2222 CharBufferScannerTest.dartSuite(); | 2293 CharBufferScannerTest.dartSuite(); |
| 2223 KeywordStateTest.dartSuite(); | 2294 KeywordStateTest.dartSuite(); |
| 2224 StringScannerTest.dartSuite(); | 2295 StringScannerTest.dartSuite(); |
| 2225 TokenTypeTest.dartSuite(); | 2296 TokenTypeTest.dartSuite(); |
| 2226 } | 2297 } |
| OLD | NEW |