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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/summary/resynthesize_common.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 3690098b1c5b37b7cc86d8aacfa255dd4e922633..1bdba6ef9812ac509379a41b73ee8eaaeb5704f5 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -3273,6 +3273,52 @@ f() {}''');
checkLibrary('f() {} g() {}');
}
+ test_futureOr() {
+ var library = checkLibrary('import "dart:async"; FutureOr<int> x;');
+ var variables = library.definingCompilationUnit.topLevelVariables;
+ expect(variables, hasLength(1));
+ if (createOptions().strongMode) {
+ expect(variables[0].type.toString(), 'FutureOr<int>');
+ } else {
+ expect(variables[0].type.toString(), 'dynamic');
+ }
+ }
+
+ test_futureOr_const() {
+ var library = checkLibrary('import "dart:async"; const x = FutureOr;');
+ var variables = library.definingCompilationUnit.topLevelVariables;
+ expect(variables, hasLength(1));
+ var x = variables[0] as ConstTopLevelVariableElementImpl;
+ if (createOptions().strongMode) {
+ expect(x.type.toString(), 'Type');
+ } else {
+ expect(x.type.toString(), 'dynamic');
+ }
+ expect(x.constantInitializer.toString(), 'FutureOr');
+ }
+
+ test_futureOr_inferred() {
+ var library = checkLibrary('''
+import "dart:async";
+FutureOr<int> f() => null;
+var x = f();
+var y = x.then((z) => z.asDouble());
+''');
+ var variables = library.definingCompilationUnit.topLevelVariables;
+ expect(variables, hasLength(2));
+ var x = variables[0];
+ expect(x.name, 'x');
+ var y = variables[1];
+ expect(y.name, 'y');
+ if (createOptions().strongMode) {
+ expect(x.type.toString(), 'FutureOr<int>');
+ expect(y.type.toString(), 'dynamic');
+ } else {
+ expect(x.type.toString(), 'dynamic');
+ expect(y.type.toString(), 'dynamic');
+ }
+ }
+
test_generic_gClass_gMethodStatic() {
prepareAnalysisContext(createOptions());
checkLibrary('''
« 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