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

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

Issue 736813002: Fix incremental parsing of function literals in initializer lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/parser_test.dart
diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
index a05201ee384926d4d28d4ad677f6752abdf1e676..2630304d425a189ae078a3c094b7d9b788011d50 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -2521,17 +2521,15 @@ class ErrorParserTest extends ParserTestCase {
}
class IncrementalParserTest extends EngineTestCase {
- void fail_replace_identifier_with_functionLiteral_in_initializer() {
- // Function literals aren't allowed inside initializers; incremental parsing
- // needs to gather the appropriate context.
+ void fail_replace_identifier_with_functionLiteral_in_initializer_interp() {
+ // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs
+
+ // Function literals are allowed inside interpolation expressions in
+ // initializers.
//
- // "class A { var a; A(b) : a = b ? b : 0 { } }"
- // "class A { var a; A(b) : a = b ? () {} : 0 { } }"
- _assertParse(
- "class A { var a; A(b) : a = b ? ",
- "b",
- "() {}",
- " : 0 { } }");
+ // 'class A { var a; A(b) : a = "${b}";'
+ // 'class A { var a; A(b) : a = "${() {}}";'
+ _assertParse(r'class A { var a; A(b) : a = "${', 'b', '() {}', '}";');
}
void test_delete_everything() {
@@ -2722,6 +2720,51 @@ class IncrementalParserTest extends EngineTestCase {
_assertParse("f() => f", "ir", "ro", "st + b;");
}
+ void test_replace_identifier_with_functionLiteral_in_initializer() {
+ // Function literals aren't allowed inside initializers; incremental parsing
+ // needs to gather the appropriate context.
+ //
+ // "class A { var a; A(b) : a = b ? b : 0 { } }"
+ // "class A { var a; A(b) : a = b ? () {} : 0 { } }"
+ _assertParse(
+ "class A { var a; A(b) : a = b ? ",
+ "b",
+ "() {}",
+ " : 0 { } }");
+ }
+
+ void test_replace_identifier_with_functionLiteral_in_initializer_index() {
+ // Function literals are allowed inside index expressions in initializers.
+ //
+ // "class A { var a; A(b) : a = b[b];"
+ // "class A { var a; A(b) : a = b[() {}];"
+ _assertParse('class A { var a; A(b) : a = b[', 'b', '() {}', '];');
+ }
+
+ void test_replace_identifier_with_functionLiteral_in_initializer_list() {
+ // Function literals are allowed inside list literals in initializers.
+ //
+ // "class A { var a; A(b) : a = [b];"
+ // "class A { var a; A(b) : a = [() {}];"
+ _assertParse('class A { var a; A(b) : a = [', 'b', '() {}', '];');
+ }
+
+ void test_replace_identifier_with_functionLiteral_in_initializer_map() {
+ // Function literals are allowed inside map literals in initializers.
+ //
+ // "class A { var a; A(b) : a = {0: b};"
+ // "class A { var a; A(b) : a = {0: () {}};"
+ _assertParse('class A { var a; A(b) : a = {0: ', 'b', '() {}', '};');
+ }
+
+ void test_replace_identifier_with_functionLiteral_in_initializer_parens() {
+ // Function literals are allowed inside parentheses in initializers.
+ //
+ // "class A { var a; A(b) : a = (b);"
+ // "class A { var a; A(b) : a = (() {});"
+ _assertParse('class A { var a; A(b) : a = (', 'b', '() {}', ');');
+ }
+
void test_replace_multiple_partialFirstAndLast() {
// "f() => aa + bb;"
// "f() => ab * ab;"
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698