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

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

Issue 1686893002: Consolidate the code that replaces a TypeParameter with its bound. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add unit tests. Created 4 years, 10 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
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.resolver_test; 5 library analyzer.test.generated.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 13984 matching lines...) Expand 10 before | Expand all | Expand 10 after
13995 _resolveTestUnit(code); 13995 _resolveTestUnit(code);
13996 13996
13997 SimpleIdentifier identifier = _findIdentifier('foo'); 13997 SimpleIdentifier identifier = _findIdentifier('foo');
13998 VariableDeclaration declaration = 13998 VariableDeclaration declaration =
13999 identifier.getAncestor((node) => node is VariableDeclaration); 13999 identifier.getAncestor((node) => node is VariableDeclaration);
14000 14000
14001 expect(declaration.initializer.staticType.toString(), "Future<String>"); 14001 expect(declaration.initializer.staticType.toString(), "Future<String>");
14002 expect(declaration.initializer.propagatedType, isNull); 14002 expect(declaration.initializer.propagatedType, isNull);
14003 } 14003 }
14004 14004
14005 void test_genericMethod_nestedBound() {
14006 String code = r'''
14007 class Foo<T extends num> {
14008 void method/*<U extends T>*/(dynamic/*=U*/ u) {
14009 u.abs();
14010 }
14011 }
14012 ''';
14013 // Just validate that there is no warning on the call to `.abs()`.
14014 _resolveTestUnit(code);
14015 }
14016
14005 void test_genericMethod_then_propagatedType() { 14017 void test_genericMethod_then_propagatedType() {
14006 // Regression test for https://github.com/dart-lang/sdk/issues/25482. 14018 // Regression test for https://github.com/dart-lang/sdk/issues/25482.
14007 String code = r''' 14019 String code = r'''
14008 import 'dart:async'; 14020 import 'dart:async';
14009 void main() { 14021 void main() {
14010 Future<String> p; 14022 Future<String> p;
14011 var foo = p.then((r) => new Future<String>.value(3)); 14023 var foo = p.then((r) => new Future<String>.value(3));
14012 } 14024 }
14013 '''; 14025 ''';
14014 // This should produce no hints or warnings. 14026 // This should produce no hints or warnings.
(...skipping 3021 matching lines...) Expand 10 before | Expand all | Expand 10 after
17036 17048
17037 void _resolveTestUnit(String code) { 17049 void _resolveTestUnit(String code) {
17038 testCode = code; 17050 testCode = code;
17039 testSource = addSource(testCode); 17051 testSource = addSource(testCode);
17040 LibraryElement library = resolve2(testSource); 17052 LibraryElement library = resolve2(testSource);
17041 assertNoErrors(testSource); 17053 assertNoErrors(testSource);
17042 verify([testSource]); 17054 verify([testSource]);
17043 testUnit = resolveCompilationUnit(testSource, library); 17055 testUnit = resolveCompilationUnit(testSource, library);
17044 } 17056 }
17045 } 17057 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | pkg/analyzer/test/src/dart/element/element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698