| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.parser_test; | 8 library engine.parser_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 | 2514 |
| 2515 void test_wrongTerminatorForParameterGroup_optional() { | 2515 void test_wrongTerminatorForParameterGroup_optional() { |
| 2516 ParserTestCase.parse4( | 2516 ParserTestCase.parse4( |
| 2517 "parseFormalParameterList", | 2517 "parseFormalParameterList", |
| 2518 "(a, [b, c})", | 2518 "(a, [b, c})", |
| 2519 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); | 2519 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2520 } | 2520 } |
| 2521 } | 2521 } |
| 2522 | 2522 |
| 2523 class IncrementalParserTest extends EngineTestCase { | 2523 class IncrementalParserTest extends EngineTestCase { |
| 2524 void fail_replace_identifier_with_functionLiteral_in_initializer() { | 2524 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() { |
| 2525 // Function literals aren't allowed inside initializers; incremental parsing | 2525 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs |
| 2526 // needs to gather the appropriate context. | 2526 |
| 2527 // Function literals are allowed inside interpolation expressions in |
| 2528 // initializers. |
| 2527 // | 2529 // |
| 2528 // "class A { var a; A(b) : a = b ? b : 0 { } }" | 2530 // 'class A { var a; A(b) : a = "${b}";' |
| 2529 // "class A { var a; A(b) : a = b ? () {} : 0 { } }" | 2531 // 'class A { var a; A(b) : a = "${() {}}";' |
| 2530 _assertParse( | 2532 _assertParse(r'class A { var a; A(b) : a = "${', 'b', '() {}', '}";'); |
| 2531 "class A { var a; A(b) : a = b ? ", | |
| 2532 "b", | |
| 2533 "() {}", | |
| 2534 " : 0 { } }"); | |
| 2535 } | 2533 } |
| 2536 | 2534 |
| 2537 void test_delete_everything() { | 2535 void test_delete_everything() { |
| 2538 // "f() => a + b;" | 2536 // "f() => a + b;" |
| 2539 // "" | 2537 // "" |
| 2540 _assertParse("", "f() => a + b;", "", ""); | 2538 _assertParse("", "f() => a + b;", "", ""); |
| 2541 } | 2539 } |
| 2542 | 2540 |
| 2543 void test_delete_identifier_beginning() { | 2541 void test_delete_identifier_beginning() { |
| 2544 // "f() => abs + b;" | 2542 // "f() => abs + b;" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2715 // "f() => belt + b;" | 2713 // "f() => belt + b;" |
| 2716 _assertParse("f() => bel", "l", "t", " + b;"); | 2714 _assertParse("f() => bel", "l", "t", " + b;"); |
| 2717 } | 2715 } |
| 2718 | 2716 |
| 2719 void test_replace_identifier_middle() { | 2717 void test_replace_identifier_middle() { |
| 2720 // "f() => first + b;" | 2718 // "f() => first + b;" |
| 2721 // "f() => frost + b;" | 2719 // "f() => frost + b;" |
| 2722 _assertParse("f() => f", "ir", "ro", "st + b;"); | 2720 _assertParse("f() => f", "ir", "ro", "st + b;"); |
| 2723 } | 2721 } |
| 2724 | 2722 |
| 2723 void test_replace_identifier_with_functionLiteral_in_initializer() { |
| 2724 // Function literals aren't allowed inside initializers; incremental parsing |
| 2725 // needs to gather the appropriate context. |
| 2726 // |
| 2727 // "class A { var a; A(b) : a = b ? b : 0 { } }" |
| 2728 // "class A { var a; A(b) : a = b ? () {} : 0 { } }" |
| 2729 _assertParse( |
| 2730 "class A { var a; A(b) : a = b ? ", |
| 2731 "b", |
| 2732 "() {}", |
| 2733 " : 0 { } }"); |
| 2734 } |
| 2735 |
| 2736 void test_replace_identifier_with_functionLiteral_in_initializer_index() { |
| 2737 // Function literals are allowed inside index expressions in initializers. |
| 2738 // |
| 2739 // "class A { var a; A(b) : a = b[b];" |
| 2740 // "class A { var a; A(b) : a = b[() {}];" |
| 2741 _assertParse('class A { var a; A(b) : a = b[', 'b', '() {}', '];'); |
| 2742 } |
| 2743 |
| 2744 void test_replace_identifier_with_functionLiteral_in_initializer_list() { |
| 2745 // Function literals are allowed inside list literals in initializers. |
| 2746 // |
| 2747 // "class A { var a; A(b) : a = [b];" |
| 2748 // "class A { var a; A(b) : a = [() {}];" |
| 2749 _assertParse('class A { var a; A(b) : a = [', 'b', '() {}', '];'); |
| 2750 } |
| 2751 |
| 2752 void test_replace_identifier_with_functionLiteral_in_initializer_map() { |
| 2753 // Function literals are allowed inside map literals in initializers. |
| 2754 // |
| 2755 // "class A { var a; A(b) : a = {0: b};" |
| 2756 // "class A { var a; A(b) : a = {0: () {}};" |
| 2757 _assertParse('class A { var a; A(b) : a = {0: ', 'b', '() {}', '};'); |
| 2758 } |
| 2759 |
| 2760 void test_replace_identifier_with_functionLiteral_in_initializer_parens() { |
| 2761 // Function literals are allowed inside parentheses in initializers. |
| 2762 // |
| 2763 // "class A { var a; A(b) : a = (b);" |
| 2764 // "class A { var a; A(b) : a = (() {});" |
| 2765 _assertParse('class A { var a; A(b) : a = (', 'b', '() {}', ');'); |
| 2766 } |
| 2767 |
| 2725 void test_replace_multiple_partialFirstAndLast() { | 2768 void test_replace_multiple_partialFirstAndLast() { |
| 2726 // "f() => aa + bb;" | 2769 // "f() => aa + bb;" |
| 2727 // "f() => ab * ab;" | 2770 // "f() => ab * ab;" |
| 2728 _assertParse("f() => a", "a + b", "b * a", "b;"); | 2771 _assertParse("f() => a", "a + b", "b * a", "b;"); |
| 2729 } | 2772 } |
| 2730 | 2773 |
| 2731 void test_replace_operator_oneForMany() { | 2774 void test_replace_operator_oneForMany() { |
| 2732 // "f() => a + b;" | 2775 // "f() => a + b;" |
| 2733 // "f() => a * c - b;" | 2776 // "f() => a * c - b;" |
| 2734 _assertParse("f() => a ", "+", "* c -", " b;"); | 2777 _assertParse("f() => a ", "+", "* c -", " b;"); |
| (...skipping 8048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10783 // Parse the source. | 10826 // Parse the source. |
| 10784 // | 10827 // |
| 10785 Parser parser = new Parser(null, listener); | 10828 Parser parser = new Parser(null, listener); |
| 10786 return invokeParserMethodImpl( | 10829 return invokeParserMethodImpl( |
| 10787 parser, | 10830 parser, |
| 10788 methodName, | 10831 methodName, |
| 10789 <Object>[tokenStream], | 10832 <Object>[tokenStream], |
| 10790 tokenStream) as Token; | 10833 tokenStream) as Token; |
| 10791 } | 10834 } |
| 10792 } | 10835 } |
| OLD | NEW |