Macro. Add a few flag tests after API changes.

After https://dart-review.googlesource.com/c/sdk/+/352540

Change-Id: Ibc56bdb3e4f7129df1c55fcf5a696d570582c02d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/test/src/summary/macro/introspect.dart b/pkg/analyzer/test/src/summary/macro/introspect.dart
index d9d855d..a1e1901 100644
--- a/pkg/analyzer/test/src/summary/macro/introspect.dart
+++ b/pkg/analyzer/test/src/summary/macro/introspect.dart
@@ -576,8 +576,10 @@
     await sink.withIndent(() async {
       await sink.writeFlags({
         'hasAbstract': e.hasAbstract,
+        'hasConst': e.hasConst,
         'hasExternal': e.hasExternal,
         'hasFinal': e.hasFinal,
+        'hasInitializer': e.hasInitializer,
         'hasLate': e.hasLate,
         'hasStatic': e.hasStatic,
       });
@@ -655,9 +657,11 @@
 
     await sink.withIndent(() async {
       await sink.writeFlags({
+        'hasConst': e.hasConst,
         'hasExternal': e.hasExternal,
         'hasFinal': e.hasFinal,
         'hasLate': e.hasLate,
+        'hasInitializer': e.hasInitializer,
       });
       await _writeMetadata(e);
       await _writeNamedTypeAnnotation('type', e.type);
diff --git a/pkg/analyzer/test/src/summary/macro_test.dart b/pkg/analyzer/test/src/summary/macro_test.dart
index 20fa83b..8d8fc25 100644
--- a/pkg/analyzer/test/src/summary/macro_test.dart
+++ b/pkg/analyzer/test/src/summary/macro_test.dart
@@ -7249,6 +7249,23 @@
 ''');
   }
 
+  test_class_field_flag_hasConst() async {
+    newFile('$testPackageLibPath/a.dart', r'''
+class A {
+  static const int foo = 0;
+}
+''');
+
+    await _assertIntrospectText('A', r'''
+class A
+  superclass: Object
+  fields
+    foo
+      flags: hasConst hasInitializer hasStatic
+      type: int
+''');
+  }
+
   test_class_field_flag_hasExternal() async {
     newFile('$testPackageLibPath/a.dart', r'''
 class A {
@@ -7278,7 +7295,7 @@
   superclass: Object
   fields
     foo
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: int
 ''');
   }
@@ -7312,7 +7329,7 @@
   superclass: Object
   fields
     foo
-      flags: hasStatic
+      flags: hasInitializer hasStatic
       type: int
 ''');
   }
@@ -7387,10 +7404,10 @@
   superclass: Object
   fields
     foo
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: int
     bar
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: int
 ''');
   }
@@ -8496,7 +8513,7 @@
     Object
   fields
     foo
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: int
 ''');
   }
@@ -8775,7 +8792,19 @@
 
     await _assertIntrospectText('foo', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
+  type: int
+''');
+  }
+
+  test_unit_variable_flags_hasConst_true() async {
+    newFile('$testPackageLibPath/a.dart', r'''
+const foo = 0;
+''');
+
+    await _assertIntrospectText('foo', r'''
+foo
+  flags: hasConst hasInitializer
   type: int
 ''');
   }
@@ -8799,10 +8828,22 @@
 
     await _assertIntrospectText('foo', r'''
 foo
+  flags: hasInitializer
   type: int
 ''');
   }
 
+  test_unit_variable_flags_hasInitializer_false() async {
+    newFile('$testPackageLibPath/a.dart', r'''
+int? foo;
+''');
+
+    await _assertIntrospectText('foo', r'''
+foo
+  type: int?
+''');
+  }
+
   test_unit_variable_flags_hasLate_true() async {
     newFile('$testPackageLibPath/a.dart', r'''
 late int foo;
@@ -8827,7 +8868,7 @@
 
     await _assertIntrospectText('foo', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   metadata
     IdentifierMetadataAnnotation
       identifier: a1
@@ -8899,7 +8940,7 @@
 class X
   fields
     foo
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: OmittedType
         inferred: int
 ''');
@@ -8919,7 +8960,7 @@
   superclass: A
   fields
     foo
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: OmittedType
         inferred: int
 ''');
@@ -8949,7 +8990,7 @@
 class A
   fields
     foo
-      flags: hasFinal hasStatic
+      flags: hasFinal hasInitializer hasStatic
       type: OmittedType
         inferred: int
 ''');
@@ -9221,7 +9262,7 @@
 final foo = 0;
 ''', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   type: OmittedType
     inferred: int
 ''');
@@ -9361,10 +9402,10 @@
 ''', r'''
 topLevelDeclarationsOf
   foo
-    flags: hasFinal
+    flags: hasFinal hasInitializer
     type: int
   bar
-    flags: hasFinal
+    flags: hasFinal hasInitializer
     type: int
 ''');
   }
@@ -9562,6 +9603,19 @@
 ''');
   }
 
+  test_class_field_flags_hasConst_true() async {
+    await _assertIntrospectText(r'''
+class X {
+  @Introspect()
+  static const int foo = 0;
+}
+''', r'''
+foo
+  flags: hasConst hasInitializer hasStatic
+  type: int
+''');
+  }
+
   test_class_field_flags_hasExternal() async {
     await _assertIntrospectText(r'''
 class X {
@@ -9583,6 +9637,7 @@
 }
 ''', r'''
 foo
+  flags: hasInitializer
   type: int
 ''');
   }
@@ -9595,11 +9650,23 @@
 }
 ''', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   type: int
 ''');
   }
 
+  test_class_field_flags_hasInitializer_false() async {
+    await _assertIntrospectText(r'''
+class X {
+  @Introspect()
+  int? foo;
+}
+''', r'''
+foo
+  type: int?
+''');
+  }
+
   test_class_field_flags_hasLate() async {
     await _assertIntrospectText(r'''
 class X {
@@ -9621,7 +9688,7 @@
 }
 ''', r'''
 foo
-  flags: hasStatic
+  flags: hasInitializer hasStatic
   type: int
 ''');
   }
@@ -9634,6 +9701,7 @@
 }
 ''', r'''
 foo
+  flags: hasInitializer
   type: int
 ''');
   }
@@ -9646,7 +9714,7 @@
 }
 ''', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   type: OmittedType
 ''');
   }
@@ -9662,9 +9730,10 @@
 class X
   fields
     foo
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: int
     bar
+      flags: hasInitializer
       type: String
 ''');
   }
@@ -10995,9 +11064,10 @@
 mixin X
   fields
     foo
-      flags: hasFinal
+      flags: hasFinal hasInitializer
       type: int
     bar
+      flags: hasInitializer
       type: String
 ''');
   }
@@ -11235,6 +11305,17 @@
 ''');
   }
 
+  test_unit_variable_flags_hasConst_true() async {
+    await _assertIntrospectText(r'''
+@Introspect()
+const foo = 0;
+''', r'''
+foo
+  flags: hasConst hasInitializer
+  type: OmittedType
+''');
+  }
+
   test_unit_variable_flags_hasExternal_true() async {
     await _assertIntrospectText(r'''
 @Introspect()
@@ -11252,6 +11333,7 @@
 var foo = 0;
 ''', r'''
 foo
+  flags: hasInitializer
   type: OmittedType
 ''');
   }
@@ -11262,7 +11344,7 @@
 final foo = 0;
 ''', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   type: OmittedType
 ''');
   }
@@ -11289,7 +11371,7 @@
 const a2 = 0;
 ''', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   metadata
     ConstructorMetadataAnnotation
       type: Introspect
@@ -11307,7 +11389,7 @@
 final num foo = 0;
 ''', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   type: num
 ''');
   }
@@ -11318,7 +11400,7 @@
 final foo = 0;
 ''', r'''
 foo
-  flags: hasFinal
+  flags: hasFinal hasInitializer
   type: OmittedType
 ''');
   }