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

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

Issue 2115173002: fix #25220, infer generic type from constructor arguments (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: update tests to be AST summary friendly Created 4 years, 5 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.strong_mode_test; 5 library analyzer.test.generated.strong_mode_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 10 import 'package:analyzer/src/dart/element/element.dart';
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 A<int, String> a2 = new D<int, String>("hello"); 791 A<int, String> a2 = new D<int, String>("hello");
792 A<int, String> a3 = new D<String, String>.named("hello"); 792 A<int, String> a3 = new D<String, String>.named("hello");
793 A<int, String> a4 = new D<num, dynamic>("hello"); 793 A<int, String> a4 = new D<num, dynamic>("hello");
794 A<int, String> a5 = new D<dynamic, dynamic>.named("hello"); 794 A<int, String> a5 = new D<dynamic, dynamic>.named("hello");
795 } 795 }
796 void test7() { 796 void test7() {
797 A<int, String> a0 = new D(3); 797 A<int, String> a0 = new D(3);
798 A<int, String> a1 = new D.named(3); 798 A<int, String> a1 = new D.named(3);
799 } 799 }
800 void test8() { 800 void test8() {
801 // Currently we only allow variable constraints. Test that we reject.
802 A<C<int>, String> a0 = new E("hello"); 801 A<C<int>, String> a0 = new E("hello");
803 } 802 }
804 void test9() { // Check named and optional arguments 803 void test9() { // Check named and optional arguments
805 A<int, String> a0 = new F(3, "hello", a: [3], b: ["hello"]); 804 A<int, String> a0 = new F(3, "hello", a: [3], b: ["hello"]);
806 A<int, String> a1 = new F(3, "hello", a: ["hello"], b:[3]); 805 A<int, String> a1 = new F(3, "hello", a: ["hello"], b:[3]);
807 A<int, String> a2 = new F.named(3, "hello", 3, "hello"); 806 A<int, String> a2 = new F.named(3, "hello", 3, "hello");
808 A<int, String> a3 = new F.named(3, "hello"); 807 A<int, String> a3 = new F.named(3, "hello");
809 A<int, String> a4 = new F.named(3, "hello", "hello", 3); 808 A<int, String> a4 = new F.named(3, "hello", "hello", 3);
810 A<int, String> a5 = new F.named(3, "hello", "hello"); 809 A<int, String> a5 = new F.named(3, "hello", "hello");
811 } 810 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 { 913 {
915 List<Statement> statements = 914 List<Statement> statements =
916 AstFinder.getStatementsInTopLevelFunction(unit, "test7"); 915 AstFinder.getStatementsInTopLevelFunction(unit, "test7");
917 hasType(assertDOf([_isDynamic, _isString]), rhs(statements[0])); 916 hasType(assertDOf([_isDynamic, _isString]), rhs(statements[0]));
918 hasType(assertDOf([_isDynamic, _isString]), rhs(statements[1])); 917 hasType(assertDOf([_isDynamic, _isString]), rhs(statements[1]));
919 } 918 }
920 919
921 { 920 {
922 List<Statement> statements = 921 List<Statement> statements =
923 AstFinder.getStatementsInTopLevelFunction(unit, "test8"); 922 AstFinder.getStatementsInTopLevelFunction(unit, "test8");
924 hasType(assertEOf([_isDynamic, _isDynamic]), rhs(statements[0])); 923 hasType(assertEOf([_isInt, _isString]), rhs(statements[0]));
925 } 924 }
926 925
927 { 926 {
928 List<Statement> statements = 927 List<Statement> statements =
929 AstFinder.getStatementsInTopLevelFunction(unit, "test9"); 928 AstFinder.getStatementsInTopLevelFunction(unit, "test9");
930 hasType(assertFOf([_isInt, _isString]), rhs(statements[0])); 929 hasType(assertFOf([_isInt, _isString]), rhs(statements[0]));
931 hasType(assertFOf([_isInt, _isString]), rhs(statements[1])); 930 hasType(assertFOf([_isInt, _isString]), rhs(statements[1]));
932 hasType(assertFOf([_isInt, _isString]), rhs(statements[2])); 931 hasType(assertFOf([_isInt, _isString]), rhs(statements[2]));
933 hasType(assertFOf([_isInt, _isString]), rhs(statements[3])); 932 hasType(assertFOf([_isInt, _isString]), rhs(statements[3]));
934 hasType(assertFOf([_isInt, _isString]), rhs(statements[4])); 933 hasType(assertFOf([_isInt, _isString]), rhs(statements[4]));
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 main() { 2307 main() {
2309 var v = x; 2308 var v = x;
2310 v; // marker 2309 v; // marker
2311 } 2310 }
2312 int x = 3; 2311 int x = 3;
2313 '''; 2312 ''';
2314 assertPropagatedAssignedType(code, typeProvider.intType, null); 2313 assertPropagatedAssignedType(code, typeProvider.intType, null);
2315 assertTypeOfMarkedExpression(code, typeProvider.intType, null); 2314 assertTypeOfMarkedExpression(code, typeProvider.intType, null);
2316 } 2315 }
2317 } 2316 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | pkg/analyzer/test/generated/type_system_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698