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

Side by Side Diff: pkg/analyzer/test/generated/incremental_resolver_test.dart

Issue 1560433002: Test for changing method to/from getter/setter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library analyzer.test.generated.incremental_resolver_test; 5 library analyzer.test.generated.incremental_resolver_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/context/cache.dart'; 8 import 'package:analyzer/src/context/cache.dart';
9 import 'package:analyzer/src/dart/element/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/error.dart'; 12 import 'package:analyzer/src/generated/error.dart';
13 import 'package:analyzer/src/generated/incremental_logger.dart' as log; 13 import 'package:analyzer/src/generated/incremental_logger.dart' as log;
14 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; 14 import 'package:analyzer/src/generated/incremental_resolution_validator.dart';
15 import 'package:analyzer/src/generated/incremental_resolver.dart'; 15 import 'package:analyzer/src/generated/incremental_resolver.dart';
16 import 'package:analyzer/src/generated/java_engine.dart'; 16 import 'package:analyzer/src/generated/java_engine.dart';
17 import 'package:analyzer/src/generated/parser.dart'; 17 import 'package:analyzer/src/generated/parser.dart';
18 import 'package:analyzer/src/generated/resolver.dart'; 18 import 'package:analyzer/src/generated/resolver.dart';
19 import 'package:analyzer/src/generated/scanner.dart'; 19 import 'package:analyzer/src/generated/scanner.dart';
20 import 'package:analyzer/src/generated/source_io.dart'; 20 import 'package:analyzer/src/generated/source_io.dart';
21 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 21 import 'package:analyzer/src/generated/testing/ast_factory.dart';
22 import 'package:analyzer/src/generated/testing/element_factory.dart'; 22 import 'package:analyzer/src/generated/testing/element_factory.dart';
23 import 'package:analyzer/src/task/dart.dart'; 23 import 'package:analyzer/src/task/dart.dart';
24 import 'package:analyzer/task/dart.dart'; 24 import 'package:analyzer/task/dart.dart';
25 import 'package:unittest/unittest.dart'; 25 import 'package:unittest/unittest.dart';
26 26
27 import '../reflective_tests.dart'; 27 import '../reflective_tests.dart';
28 import 'parser_test.dart';
29 import 'resolver_test.dart'; 28 import 'resolver_test.dart';
30 import 'test_support.dart'; 29 import 'test_support.dart';
31 30
32 main() { 31 main() {
33 initializeTestEnvironment(); 32 initializeTestEnvironment();
34 runReflectiveTests(DeclarationMatcherTest); 33 runReflectiveTests(DeclarationMatcherTest);
35 runReflectiveTests(IncrementalResolverTest); 34 runReflectiveTests(IncrementalResolverTest);
36 runReflectiveTests(PoorMansIncrementalResolutionTest); 35 runReflectiveTests(PoorMansIncrementalResolutionTest);
37 runReflectiveTests(ResolutionContextBuilderTest); 36 runReflectiveTests(ResolutionContextBuilderTest);
38 } 37 }
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 m() async* {} 1539 m() async* {}
1541 } 1540 }
1542 ''', 1541 ''',
1543 r''' 1542 r'''
1544 class A { 1543 class A {
1545 m() async {} 1544 m() async {}
1546 } 1545 }
1547 '''); 1546 ''');
1548 } 1547 }
1549 1548
1549 void test_false_method_getKeyword_add() {
1550 _assertDoesNotMatchOK(
1551 r'''
1552 class A {
1553 void foo() {}
1554 }
1555 ''',
1556 r'''
1557 class A {
1558 void get foo() {}
Brian Wilkerson 2016/01/04 18:43:09 The parens are not valid on a getter (here and on
1559 }
1560 ''');
1561 }
1562
1563 void test_false_method_getKeyword_remove() {
1564 _assertDoesNotMatchOK(
1565 r'''
1566 class A {
1567 void get foo() {}
1568 }
1569 ''',
1570 r'''
1571 class A {
1572 void foo() {}
1573 }
1574 ''');
1575 }
1576
1550 void test_false_method_list_add() { 1577 void test_false_method_list_add() {
1551 _assertDoesNotMatchOK( 1578 _assertDoesNotMatchOK(
1552 r''' 1579 r'''
1553 class A { 1580 class A {
1554 a() {} 1581 a() {}
1555 b() {} 1582 b() {}
1556 } 1583 }
1557 ''', 1584 ''',
1558 r''' 1585 r'''
1559 class A { 1586 class A {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 int m() {} 1661 int m() {}
1635 } 1662 }
1636 ''', 1663 ''',
1637 r''' 1664 r'''
1638 class A { 1665 class A {
1639 String m() {} 1666 String m() {}
1640 } 1667 }
1641 '''); 1668 ''');
1642 } 1669 }
1643 1670
1671 void test_false_method_setKeyword_add() {
1672 _assertDoesNotMatchOK(
1673 r'''
1674 class A {
1675 void foo(x) {}
1676 }
1677 ''',
1678 r'''
1679 class A {
1680 void set foo(x) {}
1681 }
1682 ''');
1683 }
1684
1685 void test_false_method_setKeyword_remove() {
1686 _assertDoesNotMatchOK(
1687 r'''
1688 class A {
1689 void set foo(x) {}
1690 }
1691 ''',
1692 r'''
1693 class A {
1694 void foo(x) {}
1695 }
1696 ''');
1697 }
1698
1644 void test_false_part_list_add() { 1699 void test_false_part_list_add() {
1645 addNamedSource('/unitA.dart', 'part of lib; class A {}'); 1700 addNamedSource('/unitA.dart', 'part of lib; class A {}');
1646 addNamedSource('/unitB.dart', 'part of lib; class B {}'); 1701 addNamedSource('/unitB.dart', 'part of lib; class B {}');
1647 _assertDoesNotMatch( 1702 _assertDoesNotMatch(
1648 r''' 1703 r'''
1649 library lib; 1704 library lib;
1650 part 'unitA.dart'; 1705 part 'unitA.dart';
1651 ''', 1706 ''',
1652 r''' 1707 r'''
1653 library lib; 1708 library lib;
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 void _assertMatches(String oldContent, String newContent) { 3051 void _assertMatches(String oldContent, String newContent) {
2997 _assertMatchKind(DeclarationMatchKind.MATCH, oldContent, newContent); 3052 _assertMatchKind(DeclarationMatchKind.MATCH, oldContent, newContent);
2998 } 3053 }
2999 3054
3000 void _assertMatchKind( 3055 void _assertMatchKind(
3001 DeclarationMatchKind expectMatch, String oldContent, String newContent) { 3056 DeclarationMatchKind expectMatch, String oldContent, String newContent) {
3002 Source source = addSource(oldContent); 3057 Source source = addSource(oldContent);
3003 LibraryElement library = resolve2(source); 3058 LibraryElement library = resolve2(source);
3004 CompilationUnit oldUnit = resolveCompilationUnit(source, library); 3059 CompilationUnit oldUnit = resolveCompilationUnit(source, library);
3005 // parse 3060 // parse
3006 CompilationUnit newUnit = ParserTestCase.parseCompilationUnit(newContent); 3061 CompilationUnit newUnit = IncrementalResolverTest._parseUnit(newContent);
3007 // build elements 3062 // build elements
3008 { 3063 {
3009 ElementHolder holder = new ElementHolder(); 3064 ElementHolder holder = new ElementHolder();
3010 ElementBuilder builder = new ElementBuilder(holder); 3065 ElementBuilder builder = new ElementBuilder(holder);
3011 newUnit.accept(builder); 3066 newUnit.accept(builder);
3012 } 3067 }
3013 // match 3068 // match
3014 DeclarationMatcher matcher = new DeclarationMatcher(); 3069 DeclarationMatcher matcher = new DeclarationMatcher();
3015 DeclarationMatchKind matchKind = matcher.matches(newUnit, oldUnit.element); 3070 DeclarationMatchKind matchKind = matcher.matches(newUnit, oldUnit.element);
3016 expect(matchKind, same(expectMatch)); 3071 expect(matchKind, same(expectMatch));
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
4960 return ResolutionContextBuilder.contextFor(node, listener).scope; 5015 return ResolutionContextBuilder.contextFor(node, listener).scope;
4961 } 5016 }
4962 } 5017 }
4963 5018
4964 class _Edit { 5019 class _Edit {
4965 final int offset; 5020 final int offset;
4966 final int length; 5021 final int length;
4967 final String replacement; 5022 final String replacement;
4968 _Edit(this.offset, this.length, this.replacement); 5023 _Edit(this.offset, this.length, this.replacement);
4969 } 5024 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698