| 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 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'; |
| 11 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 11 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 12 import 'package:analyzer/src/generated/source_io.dart'; | 12 import 'package:analyzer/src/generated/source_io.dart'; |
| 13 import 'package:unittest/unittest.dart'; |
| 13 | 14 |
| 14 import '../reflective_tests.dart'; | 15 import '../reflective_tests.dart'; |
| 15 import '../utils.dart'; | 16 import '../utils.dart'; |
| 16 import 'resolver_test.dart'; | 17 import 'resolver_test.dart'; |
| 17 import 'test_support.dart'; | 18 import 'test_support.dart'; |
| 18 | 19 |
| 19 main() { | 20 main() { |
| 20 initializeTestEnvironment(); | 21 initializeTestEnvironment(); |
| 21 runReflectiveTests(NonErrorResolverTest); | 22 runReflectiveTests(NonErrorResolverTest); |
| 22 } | 23 } |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 verify([source]); | 824 verify([source]); |
| 824 CompilationUnit unit = _getResolvedLibraryUnit(source); | 825 CompilationUnit unit = _getResolvedLibraryUnit(source); |
| 825 { | 826 { |
| 826 SimpleIdentifier ref = EngineTestCase.findNode( | 827 SimpleIdentifier ref = EngineTestCase.findNode( |
| 827 unit, code, "p]", (node) => node is SimpleIdentifier); | 828 unit, code, "p]", (node) => node is SimpleIdentifier); |
| 828 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, | 829 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement, |
| 829 ParameterElement, ref.staticElement); | 830 ParameterElement, ref.staticElement); |
| 830 } | 831 } |
| 831 } | 832 } |
| 832 | 833 |
| 834 void test_commentReference_beforeEnum() { |
| 835 String code = r''' |
| 836 /// This is the [Samurai] kind. |
| 837 enum Samurai { |
| 838 /// Use [int]. |
| 839 WITH_SWORD, |
| 840 /// Like [WITH_SWORD], but only without one. |
| 841 WITHOUT_SWORD |
| 842 }'''; |
| 843 Source source = addSource(code); |
| 844 computeLibrarySourceErrors(source); |
| 845 assertNoErrors(source); |
| 846 verify([source]); |
| 847 CompilationUnit unit = _getResolvedLibraryUnit(source); |
| 848 { |
| 849 SimpleIdentifier ref = EngineTestCase.findNode( |
| 850 unit, code, "Samurai]", (node) => node is SimpleIdentifier); |
| 851 ClassElement refElement = ref.staticElement; |
| 852 expect(refElement, isNotNull); |
| 853 expect(refElement.name, 'Samurai'); |
| 854 } |
| 855 { |
| 856 SimpleIdentifier ref = EngineTestCase.findNode( |
| 857 unit, code, "int]", (node) => node is SimpleIdentifier); |
| 858 ClassElement refElement = ref.staticElement; |
| 859 expect(refElement, isNotNull); |
| 860 expect(refElement.name, 'int'); |
| 861 } |
| 862 { |
| 863 SimpleIdentifier ref = EngineTestCase.findNode( |
| 864 unit, code, "WITH_SWORD]", (node) => node is SimpleIdentifier); |
| 865 PropertyAccessorElement refElement = ref.staticElement; |
| 866 expect(refElement, isNotNull); |
| 867 expect(refElement.name, 'WITH_SWORD'); |
| 868 } |
| 869 } |
| 870 |
| 833 void test_commentReference_beforeFunction_blockBody() { | 871 void test_commentReference_beforeFunction_blockBody() { |
| 834 String code = r''' | 872 String code = r''' |
| 835 /// [p] | 873 /// [p] |
| 836 foo(int p) { | 874 foo(int p) { |
| 837 }'''; | 875 }'''; |
| 838 Source source = addSource(code); | 876 Source source = addSource(code); |
| 839 computeLibrarySourceErrors(source); | 877 computeLibrarySourceErrors(source); |
| 840 assertNoErrors(source); | 878 assertNoErrors(source); |
| 841 verify([source]); | 879 verify([source]); |
| 842 CompilationUnit unit = _getResolvedLibraryUnit(source); | 880 CompilationUnit unit = _getResolvedLibraryUnit(source); |
| (...skipping 4873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5716 reset(); | 5754 reset(); |
| 5717 } | 5755 } |
| 5718 | 5756 |
| 5719 void _check_wrongNumberOfParametersForOperator1(String name) { | 5757 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 5720 _check_wrongNumberOfParametersForOperator(name, "a"); | 5758 _check_wrongNumberOfParametersForOperator(name, "a"); |
| 5721 } | 5759 } |
| 5722 | 5760 |
| 5723 CompilationUnit _getResolvedLibraryUnit(Source source) => | 5761 CompilationUnit _getResolvedLibraryUnit(Source source) => |
| 5724 analysisContext.getResolvedCompilationUnit2(source, source); | 5762 analysisContext.getResolvedCompilationUnit2(source, source); |
| 5725 } | 5763 } |
| OLD | NEW |