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

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

Issue 1173633002: Fix for comment references tests. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | 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 engine.non_error_resolver_test; 5 library engine.non_error_resolver_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 void test_commentReference_beforeConstructor() { 788 void test_commentReference_beforeConstructor() {
789 String code = r''' 789 String code = r'''
790 abstract class A { 790 abstract class A {
791 /// [p] 791 /// [p]
792 A(int p) {} 792 A(int p) {}
793 }'''; 793 }''';
794 Source source = addSource(code); 794 Source source = addSource(code);
795 resolve(source); 795 resolve(source);
796 assertNoErrors(source); 796 assertNoErrors(source);
797 verify([source]); 797 verify([source]);
798 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 798 CompilationUnit unit = _getResolvedLibraryUnit(source);
799 { 799 {
800 SimpleIdentifier ref = EngineTestCase.findNode( 800 SimpleIdentifier ref = EngineTestCase.findNode(
801 unit, code, "p]", (node) => node is SimpleIdentifier); 801 unit, code, "p]", (node) => node is SimpleIdentifier);
802 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, 802 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
803 ParameterElement, ref.staticElement); 803 ParameterElement, ref.staticElement);
804 } 804 }
805 } 805 }
806 806
807 void test_commentReference_beforeFunction_blockBody() { 807 void test_commentReference_beforeFunction_blockBody() {
808 String code = r''' 808 String code = r'''
809 /// [p] 809 /// [p]
810 foo(int p) { 810 foo(int p) {
811 }'''; 811 }''';
812 Source source = addSource(code); 812 Source source = addSource(code);
813 resolve(source); 813 resolve(source);
814 assertNoErrors(source); 814 assertNoErrors(source);
815 verify([source]); 815 verify([source]);
816 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 816 CompilationUnit unit = _getResolvedLibraryUnit(source);
817 SimpleIdentifier ref = EngineTestCase.findNode( 817 SimpleIdentifier ref = EngineTestCase.findNode(
818 unit, code, "p]", (node) => node is SimpleIdentifier); 818 unit, code, "p]", (node) => node is SimpleIdentifier);
819 EngineTestCase.assertInstanceOf( 819 EngineTestCase.assertInstanceOf(
820 (obj) => obj is ParameterElement, ParameterElement, ref.staticElement); 820 (obj) => obj is ParameterElement, ParameterElement, ref.staticElement);
821 } 821 }
822 822
823 void test_commentReference_beforeFunction_expressionBody() { 823 void test_commentReference_beforeFunction_expressionBody() {
824 String code = r''' 824 String code = r'''
825 /// [p] 825 /// [p]
826 foo(int p) => null;'''; 826 foo(int p) => null;''';
827 Source source = addSource(code); 827 Source source = addSource(code);
828 resolve(source); 828 resolve(source);
829 assertNoErrors(source); 829 assertNoErrors(source);
830 verify([source]); 830 verify([source]);
831 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 831 CompilationUnit unit = _getResolvedLibraryUnit(source);
832 SimpleIdentifier ref = EngineTestCase.findNode( 832 SimpleIdentifier ref = EngineTestCase.findNode(
833 unit, code, "p]", (node) => node is SimpleIdentifier); 833 unit, code, "p]", (node) => node is SimpleIdentifier);
834 EngineTestCase.assertInstanceOf( 834 EngineTestCase.assertInstanceOf(
835 (obj) => obj is ParameterElement, ParameterElement, ref.staticElement); 835 (obj) => obj is ParameterElement, ParameterElement, ref.staticElement);
836 } 836 }
837 837
838 void test_commentReference_beforeMethod() { 838 void test_commentReference_beforeMethod() {
839 String code = r''' 839 String code = r'''
840 abstract class A { 840 abstract class A {
841 /// [p1] 841 /// [p1]
842 ma(int p1) {} 842 ma(int p1) {}
843 /// [p2] 843 /// [p2]
844 mb(int p2); 844 mb(int p2);
845 }'''; 845 }''';
846 Source source = addSource(code); 846 Source source = addSource(code);
847 resolve(source); 847 resolve(source);
848 assertNoErrors(source); 848 assertNoErrors(source);
849 verify([source]); 849 verify([source]);
850 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 850 CompilationUnit unit = _getResolvedLibraryUnit(source);
851 { 851 {
852 SimpleIdentifier ref = EngineTestCase.findNode( 852 SimpleIdentifier ref = EngineTestCase.findNode(
853 unit, code, "p1]", (node) => node is SimpleIdentifier); 853 unit, code, "p1]", (node) => node is SimpleIdentifier);
854 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, 854 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
855 ParameterElement, ref.staticElement); 855 ParameterElement, ref.staticElement);
856 } 856 }
857 { 857 {
858 SimpleIdentifier ref = EngineTestCase.findNode( 858 SimpleIdentifier ref = EngineTestCase.findNode(
859 unit, code, "p2]", (node) => node is SimpleIdentifier); 859 unit, code, "p2]", (node) => node is SimpleIdentifier);
860 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, 860 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
861 ParameterElement, ref.staticElement); 861 ParameterElement, ref.staticElement);
862 } 862 }
863 } 863 }
864 864
865 void test_commentReference_class() { 865 void test_commentReference_class() {
866 String code = r''' 866 String code = r'''
867 /// [foo] 867 /// [foo]
868 class A { 868 class A {
869 foo() {} 869 foo() {}
870 }'''; 870 }''';
871 Source source = addSource(code); 871 Source source = addSource(code);
872 resolve(source); 872 resolve(source);
873 assertNoErrors(source); 873 assertNoErrors(source);
874 verify([source]); 874 verify([source]);
875 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 875 CompilationUnit unit = _getResolvedLibraryUnit(source);
876 SimpleIdentifier ref = EngineTestCase.findNode( 876 SimpleIdentifier ref = EngineTestCase.findNode(
877 unit, code, "foo]", (node) => node is SimpleIdentifier); 877 unit, code, "foo]", (node) => node is SimpleIdentifier);
878 EngineTestCase.assertInstanceOf( 878 EngineTestCase.assertInstanceOf(
879 (obj) => obj is MethodElement, MethodElement, ref.staticElement); 879 (obj) => obj is MethodElement, MethodElement, ref.staticElement);
880 } 880 }
881 881
882 void test_commentReference_setter() { 882 void test_commentReference_setter() {
883 String code = r''' 883 String code = r'''
884 class A { 884 class A {
885 /// [x] in A 885 /// [x] in A
886 mA() {} 886 mA() {}
887 set x(value) {} 887 set x(value) {}
888 } 888 }
889 class B extends A { 889 class B extends A {
890 /// [x] in B 890 /// [x] in B
891 mB() {} 891 mB() {}
892 } 892 }
893 '''; 893 ''';
894 Source source = addSource(code); 894 Source source = addSource(code);
895 resolve(source); 895 resolve(source);
896 assertNoErrors(source); 896 assertNoErrors(source);
897 verify([source]); 897 verify([source]);
898 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 898 CompilationUnit unit = _getResolvedLibraryUnit(source);
899 { 899 {
900 SimpleIdentifier ref = EngineTestCase.findNode( 900 SimpleIdentifier ref = EngineTestCase.findNode(
901 unit, code, "x] in A", (node) => node is SimpleIdentifier); 901 unit, code, "x] in A", (node) => node is SimpleIdentifier);
902 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, 902 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement,
903 PropertyAccessorElement, ref.staticElement); 903 PropertyAccessorElement, ref.staticElement);
904 } 904 }
905 { 905 {
906 SimpleIdentifier ref = EngineTestCase.findNode( 906 SimpleIdentifier ref = EngineTestCase.findNode(
907 unit, code, "x] in B", (node) => node is SimpleIdentifier); 907 unit, code, "x] in B", (node) => node is SimpleIdentifier);
908 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, 908 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement,
(...skipping 4593 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 }"""); 5502 }""");
5503 resolve(source); 5503 resolve(source);
5504 assertNoErrors(source); 5504 assertNoErrors(source);
5505 verify([source]); 5505 verify([source]);
5506 reset(); 5506 reset();
5507 } 5507 }
5508 5508
5509 void _check_wrongNumberOfParametersForOperator1(String name) { 5509 void _check_wrongNumberOfParametersForOperator1(String name) {
5510 _check_wrongNumberOfParametersForOperator(name, "a"); 5510 _check_wrongNumberOfParametersForOperator(name, "a");
5511 } 5511 }
5512
5513 CompilationUnit _getResolvedLibraryUnit(Source source) =>
5514 analysisContext.getResolvedCompilationUnit2(source, source);
5512 } 5515 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698