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

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

Issue 2856463004: New tests and improvements for generics in comments parsing. (Closed)
Patch Set: Created 3 years, 7 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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 void test8() { 1496 void test8() {
1497 A<C<int>, String> a0 = new E("hello"); 1497 A<C<int>, String> a0 = new E("hello");
1498 } 1498 }
1499 void test9() { // Check named and optional arguments 1499 void test9() { // Check named and optional arguments
1500 A<int, String> a0 = new F(3, "hello", a: [3], b: ["hello"]); 1500 A<int, String> a0 = new F(3, "hello", a: [3], b: ["hello"]);
1501 A<int, String> a1 = new F(3, "hello", a: ["hello"], b:[3]); 1501 A<int, String> a1 = new F(3, "hello", a: ["hello"], b:[3]);
1502 A<int, String> a2 = new F.named(3, "hello", 3, "hello"); 1502 A<int, String> a2 = new F.named(3, "hello", 3, "hello");
1503 A<int, String> a3 = new F.named(3, "hello"); 1503 A<int, String> a3 = new F.named(3, "hello");
1504 A<int, String> a4 = new F.named(3, "hello", "hello", 3); 1504 A<int, String> a4 = new F.named(3, "hello", "hello", 3);
1505 A<int, String> a5 = new F.named(3, "hello", "hello"); 1505 A<int, String> a5 = new F.named(3, "hello", "hello");
1506 } 1506 }''';
1507 }''';
1508 CompilationUnit unit = await resolveSource(code); 1507 CompilationUnit unit = await resolveSource(code);
1509 1508
1510 Expression rhs(VariableDeclarationStatement stmt) { 1509 Expression rhs(VariableDeclarationStatement stmt) {
1511 VariableDeclaration decl = stmt.variables.variables[0]; 1510 VariableDeclaration decl = stmt.variables.variables[0];
1512 Expression exp = decl.initializer; 1511 Expression exp = decl.initializer;
1513 return exp; 1512 return exp;
1514 } 1513 }
1515 1514
1516 void hasType(Asserter<DartType> assertion, Expression exp) => 1515 void hasType(Asserter<DartType> assertion, Expression exp) =>
1517 assertion(exp.staticType); 1516 assertion(exp.staticType);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 assertMapOfIntToDynamic(literal(0)); 1859 assertMapOfIntToDynamic(literal(0));
1861 assertMapOfIntToDynamic(literal(1)); 1860 assertMapOfIntToDynamic(literal(1));
1862 assertMapOfIntToDynamic(literal(2)); 1861 assertMapOfIntToDynamic(literal(2));
1863 assertMapOfIntToDynamic(literal(3)); 1862 assertMapOfIntToDynamic(literal(3));
1864 } 1863 }
1865 1864
1866 test_methodDeclaration_body_propagation() async { 1865 test_methodDeclaration_body_propagation() async {
1867 String code = r''' 1866 String code = r'''
1868 class A { 1867 class A {
1869 List<String> m0(int x) => ["hello"]; 1868 List<String> m0(int x) => ["hello"];
1870 List<String> m1(int x) {return [3];}; 1869 List<String> m1(int x) {return [3];}
1871 } 1870 }
1872 '''; 1871 ''';
1873 CompilationUnit unit = await resolveSource(code); 1872 CompilationUnit unit = await resolveSource(code);
1874 Expression methodReturnValue(String methodName) { 1873 Expression methodReturnValue(String methodName) {
1875 MethodDeclaration method = 1874 MethodDeclaration method =
1876 AstFinder.getMethodInClass(unit, "A", methodName); 1875 AstFinder.getMethodInClass(unit, "A", methodName);
1877 FunctionBody body = method.body; 1876 FunctionBody body = method.body;
1878 if (body is ExpressionFunctionBody) { 1877 if (body is ExpressionFunctionBody) {
1879 return body.expression; 1878 return body.expression;
1880 } else { 1879 } else {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 ExpressionFunctionBody body = test.functionExpression.body; 2269 ExpressionFunctionBody body = test.functionExpression.body;
2271 MethodInvocation call = body.expression; 2270 MethodInvocation call = body.expression;
2272 _isNum(call.staticType); 2271 _isNum(call.staticType);
2273 _isFunction2Of(_isFunction2Of(_isString, _isNum), _isNum)( 2272 _isFunction2Of(_isFunction2Of(_isString, _isNum), _isNum)(
2274 call.staticInvokeType); 2273 call.staticInvokeType);
2275 } 2274 }
2276 2275
2277 test_superConstructorInvocation_propagation() async { 2276 test_superConstructorInvocation_propagation() async {
2278 String code = r''' 2277 String code = r'''
2279 class B { 2278 class B {
2280 B(List<String>); 2279 B(List<String> p);
2281 } 2280 }
2282 class A extends B { 2281 class A extends B {
2283 A() : super([]); 2282 A() : super([]);
2284 } 2283 }
2285 '''; 2284 ''';
2286 CompilationUnit unit = await resolveSource(code); 2285 CompilationUnit unit = await resolveSource(code);
2287 2286
2288 ConstructorDeclaration constructor = 2287 ConstructorDeclaration constructor =
2289 AstFinder.getConstructorInClass(unit, "A", null); 2288 AstFinder.getConstructorInClass(unit, "A", null);
2290 SuperConstructorInvocation invocation = constructor.initializers[0]; 2289 SuperConstructorInvocation invocation = constructor.initializers[0];
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 var v = x; 3920 var v = x;
3922 v; // marker 3921 v; // marker
3923 } 3922 }
3924 int x = 3; 3923 int x = 3;
3925 '''; 3924 ''';
3926 CompilationUnit unit = await resolveSource(code); 3925 CompilationUnit unit = await resolveSource(code);
3927 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); 3926 assertPropagatedAssignedType(code, unit, typeProvider.intType, null);
3928 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); 3927 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null);
3929 } 3928 }
3930 } 3929 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698