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

Unified Diff: pkg/analyzer/test/generated/scanner_test.dart

Issue 229653004: New analyzer snapshot with MapIterator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | pkg/analyzer/test/generated/test_support.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/scanner_test.dart
diff --git a/pkg/analyzer/test/generated/scanner_test.dart b/pkg/analyzer/test/generated/scanner_test.dart
index 0d521886d7ec31be052af6aad2fe7491d5470382..9bbf199d046cd9d4fe5b0c3488af4bf67601eb9a 100644
--- a/pkg/analyzer/test/generated/scanner_test.dart
+++ b/pkg/analyzer/test/generated/scanner_test.dart
@@ -302,6 +302,14 @@ class TokenStreamValidator {
}
class ScannerTest extends JUnitTestCase {
+ void fail_incomplete_string_interpolation() {
+ // https://code.google.com/p/dart/issues/detail?id=18073
+ _assertErrorAndTokens(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 9, "\"foo \${bar", [
+ new StringToken(TokenType.STRING, "\"foo ", 0),
+ new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 5),
+ new StringToken(TokenType.IDENTIFIER, "bar", 7)]);
+ }
+
void test_ampersand() {
_assertToken(TokenType.AMPERSAND, "&");
}
@@ -471,7 +479,7 @@ class ScannerTest extends JUnitTestCase {
}
void test_illegalChar_cyrillicLetter_middle() {
- _assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "Shche\u0433lov");
+ _assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 5, "Shche\u0433lov");
}
void test_illegalChar_cyrillicLetter_start() {
@@ -542,6 +550,10 @@ class ScannerTest extends JUnitTestCase {
_assertKeywordToken("default");
}
+ void test_keyword_deferred() {
+ _assertKeywordToken("deferred");
+ }
+
void test_keyword_do() {
_assertKeywordToken("do");
}
@@ -1092,6 +1104,22 @@ class ScannerTest extends JUnitTestCase {
}
/**
+ * Assert that scanning the given source produces an error with the given code, and also produces
+ * the given tokens.
+ *
+ * @param expectedError the error that should be produced
+ * @param expectedOffset the string offset that should be associated with the error
+ * @param source the source to be scanned to produce the error
+ * @param expectedTokens the tokens that are expected to be in the source
+ */
+ void _assertErrorAndTokens(ScannerErrorCode expectedError, int expectedOffset, String source, List<Token> expectedTokens) {
+ GatheringErrorListener listener = new GatheringErrorListener();
+ Token token = _scanWithListener(source, listener);
+ listener.assertErrors([new AnalysisError.con2(null, expectedOffset, 1, expectedError, [source.codeUnitAt(expectedOffset)])]);
+ _checkTokens(token, expectedTokens);
+ }
+
+ /**
* Assert that when scanned the given source contains a single keyword token with the same lexeme
* as the original source.
*
@@ -1190,7 +1218,12 @@ class ScannerTest extends JUnitTestCase {
*/
void _assertTokens(String source, List<Token> expectedTokens) {
Token token = _scan(source);
- JUnitTestCase.assertNotNull(token);
+ _checkTokens(token, expectedTokens);
+ }
+
+ void _checkTokens(Token firstToken, List<Token> expectedTokens) {
+ JUnitTestCase.assertNotNull(firstToken);
+ Token token = firstToken;
for (int i = 0; i < expectedTokens.length; i++) {
Token expectedToken = expectedTokens[i];
JUnitTestCase.assertEqualsMsg("Wrong type for token ${i}", expectedToken.type, token.type);
@@ -1455,6 +1488,10 @@ class ScannerTest extends JUnitTestCase {
final __test = new ScannerTest();
runJUnitTest(__test, __test.test_keyword_default);
});
+ _ut.test('test_keyword_deferred', () {
+ final __test = new ScannerTest();
+ runJUnitTest(__test, __test.test_keyword_deferred);
+ });
_ut.test('test_keyword_do', () {
final __test = new ScannerTest();
runJUnitTest(__test, __test.test_keyword_do);
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | pkg/analyzer/test/generated/test_support.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698