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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_common.dart

Issue 2647833002: fix #28008, fix #28009 implement FutureOr<T> (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into 28008_futureort Created 3 years, 11 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
9 import 'package:analyzer/dart/constant/value.dart'; 9 import 'package:analyzer/dart/constant/value.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 3255 matching lines...) Expand 10 before | Expand all | Expand 10 after
3266 3266
3267 test_function_type_parameter_with_function_typed_parameter() { 3267 test_function_type_parameter_with_function_typed_parameter() {
3268 prepareAnalysisContext(createOptions()); 3268 prepareAnalysisContext(createOptions());
3269 checkLibrary('void f<T, U>(T x(U u)) {}'); 3269 checkLibrary('void f<T, U>(T x(U u)) {}');
3270 } 3270 }
3271 3271
3272 test_functions() { 3272 test_functions() {
3273 checkLibrary('f() {} g() {}'); 3273 checkLibrary('f() {} g() {}');
3274 } 3274 }
3275 3275
3276 test_futureOr() {
3277 var library = checkLibrary('import "dart:async"; FutureOr<int> x;');
3278 var variables = library.definingCompilationUnit.topLevelVariables;
3279 expect(variables, hasLength(1));
3280 if (createOptions().strongMode) {
3281 expect(variables[0].type.toString(), 'FutureOr<int>');
3282 } else {
3283 expect(variables[0].type.toString(), 'dynamic');
3284 }
3285 }
3286
3287 test_futureOr_const() {
3288 var library = checkLibrary('import "dart:async"; const x = FutureOr;');
3289 var variables = library.definingCompilationUnit.topLevelVariables;
3290 expect(variables, hasLength(1));
3291 var x = variables[0] as ConstTopLevelVariableElementImpl;
3292 if (createOptions().strongMode) {
3293 expect(x.type.toString(), 'Type');
3294 } else {
3295 expect(x.type.toString(), 'dynamic');
3296 }
3297 expect(x.constantInitializer.toString(), 'FutureOr');
3298 }
3299
3300 test_futureOr_inferred() {
3301 var library = checkLibrary('''
3302 import "dart:async";
3303 FutureOr<int> f() => null;
3304 var x = f();
3305 var y = x.then((z) => z.asDouble());
3306 ''');
3307 var variables = library.definingCompilationUnit.topLevelVariables;
3308 expect(variables, hasLength(2));
3309 var x = variables[0];
3310 expect(x.name, 'x');
3311 var y = variables[1];
3312 expect(y.name, 'y');
3313 if (createOptions().strongMode) {
3314 expect(x.type.toString(), 'FutureOr<int>');
3315 expect(y.type.toString(), 'dynamic');
3316 } else {
3317 expect(x.type.toString(), 'dynamic');
3318 expect(y.type.toString(), 'dynamic');
3319 }
3320 }
3321
3276 test_generic_gClass_gMethodStatic() { 3322 test_generic_gClass_gMethodStatic() {
3277 prepareAnalysisContext(createOptions()); 3323 prepareAnalysisContext(createOptions());
3278 checkLibrary(''' 3324 checkLibrary('''
3279 class C<T, U> { 3325 class C<T, U> {
3280 static void m<V, W>(V v, W w) { 3326 static void m<V, W>(V v, W w) {
3281 void f<X, Y>(V v, W w, X x, Y y) { 3327 void f<X, Y>(V v, W w, X x, Y y) {
3282 } 3328 }
3283 } 3329 }
3284 } 3330 }
3285 '''); 3331 ''');
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
4967 fail('Unexpectedly tried to get unlinked summary for $uri'); 5013 fail('Unexpectedly tried to get unlinked summary for $uri');
4968 } 5014 }
4969 return serializedUnit; 5015 return serializedUnit;
4970 } 5016 }
4971 5017
4972 @override 5018 @override
4973 bool hasLibrarySummary(String uri) { 5019 bool hasLibrarySummary(String uri) {
4974 return true; 5020 return true;
4975 } 5021 }
4976 } 5022 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_ast_test.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698