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

Unified Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1936403002: Serialize / resynthesize 'isAsynchronous' and 'isGenerator' flags. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index c50e33b29f2ef2ff02addf59b0fd57ccb8cc18c8..cf863219e17a9d2f77c1ff50d53e88e34cfb5b68 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -3142,7 +3142,9 @@ const v = p.C.foo;
findExecutable('', executables: serializeClassText(text).executables);
expect(executable.kind, UnlinkedExecutableKind.constructor);
expect(executable.returnType, isNull);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, isFalse);
+ expect(executable.isGenerator, isFalse);
expect(executable.nameOffset, text.indexOf('C();'));
expect(executable.periodOffset, 0);
expect(executable.nameEnd, 0);
@@ -4738,7 +4740,9 @@ enum E {
UnlinkedExecutable executable = serializeExecutableText(text);
expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
expect(executable.returnType, isNull);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, isFalse);
+ expect(executable.isGenerator, isFalse);
expect(executable.nameOffset, text.indexOf('f'));
expect(executable.visibleOffset, 0);
expect(executable.visibleLength, 0);
@@ -4749,6 +4753,24 @@ enum E {
expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0);
}
+ test_executable_function_async() {
+ UnlinkedExecutable executable = serializeExecutableText(r'''
+import 'dart:async';
+Future f() async {}
+''');
+ expect(executable.isAsynchronous, isTrue);
+ expect(executable.isGenerator, isFalse);
+ }
+
+ test_executable_function_asyncStar() {
+ UnlinkedExecutable executable = serializeExecutableText(r'''
+import 'dart:async';
+Stream f() async* {}
+''');
+ expect(executable.isAsynchronous, isTrue);
+ expect(executable.isGenerator, isTrue);
+ }
+
test_executable_function_explicit_return() {
UnlinkedExecutable executable =
serializeExecutableText('dynamic f() => null;');
@@ -4770,7 +4792,9 @@ enum E {
UnlinkedExecutable executable = serializeExecutableText(text);
expect(executable.kind, UnlinkedExecutableKind.getter);
expect(executable.returnType, isNotNull);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, isFalse);
+ expect(executable.isGenerator, isFalse);
expect(executable.nameOffset, text.indexOf('f'));
expect(findVariable('f'), isNull);
expect(findExecutable('f='), isNull);
@@ -5203,12 +5227,38 @@ get g { // 1
executables: serializeClassText('class C { f() {} }').executables);
expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
expect(executable.returnType, isNull);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, isFalse);
+ expect(executable.isGenerator, isFalse);
expect(executable.visibleOffset, 0);
expect(executable.visibleLength, 0);
_assertCodeRange(executable.codeRange, 10, 6);
}
+ test_executable_member_function_async() {
+ UnlinkedExecutable executable =
+ findExecutable('f', executables: serializeClassText(r'''
+import 'dart:async';
+class C {
+ Future f() async {}
+}
+''').executables);
+ expect(executable.isAsynchronous, isTrue);
+ expect(executable.isGenerator, isFalse);
+ }
+
+ test_executable_member_function_asyncStar() {
+ UnlinkedExecutable executable =
+ findExecutable('f', executables: serializeClassText(r'''
+import 'dart:async';
+class C {
+ Stream f() async* {}
+}
+''').executables);
+ expect(executable.isAsynchronous, isTrue);
+ expect(executable.isGenerator, isTrue);
+ }
+
test_executable_member_function_explicit_return() {
UnlinkedExecutable executable = findExecutable('f',
executables:
@@ -5229,7 +5279,9 @@ get g { // 1
findExecutable('f', executables: cls.executables, failIfAbsent: true);
expect(executable.kind, UnlinkedExecutableKind.getter);
expect(executable.returnType, isNotNull);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, isFalse);
+ expect(executable.isGenerator, isFalse);
_assertCodeRange(executable.codeRange, 10, 15);
expect(findVariable('f', variables: cls.fields), isNull);
expect(findExecutable('f=', executables: cls.executables), isNull);
@@ -5248,7 +5300,9 @@ get g { // 1
findExecutable('f=', executables: cls.executables, failIfAbsent: true);
expect(executable.kind, UnlinkedExecutableKind.setter);
expect(executable.returnType, isNotNull);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, isFalse);
+ expect(executable.isGenerator, isFalse);
_assertCodeRange(executable.codeRange, 10, 20);
expect(findVariable('f', variables: cls.fields), isNull);
expect(findExecutable('f', executables: cls.executables), isNull);
@@ -5302,8 +5356,10 @@ get g { // 1
expect(executable.name, '+');
expect(executable.returnType, isNotNull);
expect(executable.isAbstract, false);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isConst, false);
expect(executable.isFactory, false);
+ expect(executable.isGenerator, isFalse);
expect(executable.isStatic, false);
expect(executable.parameters, hasLength(1));
checkTypeRef(executable.returnType, null, null, 'C');
@@ -5316,7 +5372,9 @@ get g { // 1
serializeClassText('class C { C operator+(C c); }', allowErrors: true)
.executables[0];
expect(executable.isAbstract, true);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, false);
+ expect(executable.isGenerator, isFalse);
}
test_executable_operator_equal() {
@@ -5331,7 +5389,9 @@ get g { // 1
serializeClassText('class C { external C operator+(C c); }')
.executables[0];
expect(executable.isAbstract, false);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, true);
+ expect(executable.isGenerator, isFalse);
}
test_executable_operator_greater_equal() {
@@ -5582,7 +5642,9 @@ f(MyFunction myFunction) {}
serializeExecutableText(text, executableName: 'f=');
expect(executable.kind, UnlinkedExecutableKind.setter);
expect(executable.returnType, isNotNull);
+ expect(executable.isAsynchronous, isFalse);
expect(executable.isExternal, isFalse);
+ expect(executable.isGenerator, isFalse);
expect(executable.nameOffset, text.indexOf('f'));
expect(findVariable('f'), isNull);
expect(findExecutable('f'), isNull);
« pkg/analyzer/lib/src/summary/idl.dart ('K') | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698