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

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

Issue 2647833002: fix #28008, fix #28009 implement FutureOr<T> (Closed)
Patch Set: add test 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 3269 matching lines...) Expand 10 before | Expand all | Expand 10 after
3280 3280
3281 test_function_type_parameter_with_function_typed_parameter() { 3281 test_function_type_parameter_with_function_typed_parameter() {
3282 prepareAnalysisContext(createOptions()); 3282 prepareAnalysisContext(createOptions());
3283 checkLibrary('void f<T, U>(T x(U u)) {}'); 3283 checkLibrary('void f<T, U>(T x(U u)) {}');
3284 } 3284 }
3285 3285
3286 test_functions() { 3286 test_functions() {
3287 checkLibrary('f() {} g() {}'); 3287 checkLibrary('f() {} g() {}');
3288 } 3288 }
3289 3289
3290 test_futureOr() {
3291 var library = checkLibrary('import "dart:async"; FutureOr<int> x;');
3292 var variables = library.definingCompilationUnit.topLevelVariables;
3293 expect(variables, hasLength(1));
3294 if (createOptions().strongMode) {
3295 expect(variables[0].type.toString(), 'FutureOr<int>');
3296 } else {
3297 expect(variables[0].type.toString(), 'dynamic');
3298 }
3299 }
3300
3301 test_futureOr_const() {
3302 var library = checkLibrary('import "dart:async"; const x = FutureOr;');
3303 var variables = library.definingCompilationUnit.topLevelVariables;
3304 expect(variables, hasLength(1));
3305 var x = variables[0] as ConstTopLevelVariableElementImpl;
3306 if (createOptions().strongMode) {
3307 expect(x.type.toString(), 'Type');
3308 } else {
3309 expect(x.type.toString(), 'dynamic');
3310 }
3311 expect(x.constantInitializer.toString(), 'FutureOr');
3312 }
3313
3314 test_futureOr_inferred() {
3315 var library = checkLibrary('''
3316 import "dart:async";
3317 FutureOr<int> f() => null;
3318 var x = f();
3319 var y = x.then((z) => z.asDouble());
3320 ''');
3321 var variables = library.definingCompilationUnit.topLevelVariables;
3322 expect(variables, hasLength(2));
3323 var x = variables[0];
3324 expect(x.name, 'x');
3325 var y = variables[1];
3326 expect(y.name, 'y');
3327 if (createOptions().strongMode) {
3328 expect(x.type.toString(), 'FutureOr<int>');
3329 expect(y.type.toString(), 'dynamic');
3330 } else {
3331 expect(x.type.toString(), 'dynamic');
3332 expect(y.type.toString(), 'dynamic');
3333 }
3334 }
3335
3290 test_generic_gClass_gMethodStatic() { 3336 test_generic_gClass_gMethodStatic() {
3291 prepareAnalysisContext(createOptions()); 3337 prepareAnalysisContext(createOptions());
3292 checkLibrary(''' 3338 checkLibrary('''
3293 class C<T, U> { 3339 class C<T, U> {
3294 static void m<V, W>(V v, W w) { 3340 static void m<V, W>(V v, W w) {
3295 void f<X, Y>(V v, W w, X x, Y y) { 3341 void f<X, Y>(V v, W w, X x, Y y) {
3296 } 3342 }
3297 } 3343 }
3298 } 3344 }
3299 '''); 3345 ''');
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
4898 fail('Unexpectedly tried to get unlinked summary for $uri'); 4944 fail('Unexpectedly tried to get unlinked summary for $uri');
4899 } 4945 }
4900 return serializedUnit; 4946 return serializedUnit;
4901 } 4947 }
4902 4948
4903 @override 4949 @override
4904 bool hasLibrarySummary(String uri) { 4950 bool hasLibrarySummary(String uri) {
4905 return true; 4951 return true;
4906 } 4952 }
4907 } 4953 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698