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

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

Issue 1166503004: Add correct test for issue 23523 (Closed) Base URL: https://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 | pkg/analyzer/test/generated/resolver_test.dart » ('j') | 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 // 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.element_test; 8 library engine.element_test;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analyzer/src/generated/element.dart';
12 import 'package:analyzer/src/generated/engine.dart' 12 import 'package:analyzer/src/generated/engine.dart'
13 show AnalysisContext, AnalysisContextImpl; 13 show AnalysisContext, AnalysisContextImpl, AnalysisOptionsImpl;
14 import 'package:analyzer/src/generated/java_core.dart'; 14 import 'package:analyzer/src/generated/java_core.dart';
15 import 'package:analyzer/src/generated/source_io.dart'; 15 import 'package:analyzer/src/generated/source_io.dart';
16 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 16 import 'package:analyzer/src/generated/testing/ast_factory.dart';
17 import 'package:analyzer/src/generated/testing/element_factory.dart'; 17 import 'package:analyzer/src/generated/testing/element_factory.dart';
18 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; 18 import 'package:analyzer/src/generated/testing/test_type_provider.dart';
19 import 'package:unittest/unittest.dart'; 19 import 'package:unittest/unittest.dart';
20 20
21 import '../reflective_tests.dart'; 21 import '../reflective_tests.dart';
22 import 'resolver_test.dart' show TestTypeProvider, AnalysisContextHelper; 22 import 'resolver_test.dart' show TestTypeProvider, AnalysisContextHelper;
23 import 'test_support.dart'; 23 import 'test_support.dart';
(...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after
3887 } 3887 }
3888 // m2 3888 // m2
3889 { 3889 {
3890 MethodElement m2Element = unitElement.getType("A").getMethod('m2'); 3890 MethodElement m2Element = unitElement.getType("A").getMethod('m2');
3891 MethodDeclaration m2Node = m2Element.computeNode(); 3891 MethodDeclaration m2Node = m2Element.computeNode();
3892 expect(m2Node, isNotNull); 3892 expect(m2Node, isNotNull);
3893 expect(m2Node.name.name, "m2"); 3893 expect(m2Node.name.name, "m2");
3894 expect(m2Node.element, same(m2Element)); 3894 expect(m2Node.element, same(m2Element));
3895 } 3895 }
3896 } 3896 }
3897
3898 void test_computeNode_withoutFunctionBody() {
3899 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
3900 options.analyzeFunctionBodies = false;
3901 AnalysisContextHelper contextHelper = new AnalysisContextHelper(options);
3902 AnalysisContext context = contextHelper.context;
3903 Source source = contextHelper.addSource("/test.dart", r'''
3904 abstract class A {
3905 String m1() => null;
3906 m2();
3907 }
3908 ''');
3909 // prepare CompilationUnitElement
3910 LibraryElement libraryElement = context.computeLibraryElement(source);
3911 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit;
3912 // m1
3913 {
3914 MethodElement m1Element = unitElement.getType("A").getMethod('m1');
3915 MethodDeclaration m1Node = m1Element.computeNode();
3916 expect(m1Node, isNotNull);
3917 expect(m1Node.name.name, "m1");
3918 expect(m1Node.element, same(m1Element));
3919 }
3920 // m2
3921 {
3922 MethodElement m2Element = unitElement.getType("A").getMethod('m2');
3923 MethodDeclaration m2Node = m2Element.computeNode();
3924 expect(m2Node, isNotNull);
3925 expect(m2Node.name.name, "m2");
3926 expect(m2Node.element, same(m2Element));
3927 }
3928 }
3897 } 3929 }
3898 3930
3899 @reflectiveTest 3931 @reflectiveTest
3900 class MultiplyDefinedElementImplTest extends EngineTestCase { 3932 class MultiplyDefinedElementImplTest extends EngineTestCase {
3901 void test_fromElements_conflicting() { 3933 void test_fromElements_conflicting() {
3902 Element firstElement = ElementFactory.localVariableElement2("xx"); 3934 Element firstElement = ElementFactory.localVariableElement2("xx");
3903 Element secondElement = ElementFactory.localVariableElement2("yy"); 3935 Element secondElement = ElementFactory.localVariableElement2("yy");
3904 Element result = MultiplyDefinedElementImpl.fromElements( 3936 Element result = MultiplyDefinedElementImpl.fromElements(
3905 null, firstElement, secondElement); 3937 null, firstElement, secondElement);
3906 EngineTestCase.assertInstanceOf( 3938 EngineTestCase.assertInstanceOf(
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
4188 } 4220 }
4189 4221
4190 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction 4222 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction
4191 extends InterfaceTypeImpl { 4223 extends InterfaceTypeImpl {
4192 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) 4224 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0)
4193 : super(arg0); 4225 : super(arg0);
4194 4226
4195 @override 4227 @override
4196 bool get isDartCoreFunction => true; 4228 bool get isDartCoreFunction => true;
4197 } 4229 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698