Fix a few mistakes and oversights in the control flow collection tests.

- Use "{" and "}" for maps.
- Add tests for Object and non-Iterable in for-in loop.
- Fix copy/paste error in inference test.

Change-Id: I563df4e94e221a1a03bbc52cf6f312aae5e07310
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97524
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
diff --git a/tests/language_2/control_flow_collections/for_inference_test.dart b/tests/language_2/control_flow_collections/for_inference_test.dart
index 54b3141..9479dd6 100644
--- a/tests/language_2/control_flow_collections/for_inference_test.dart
+++ b/tests/language_2/control_flow_collections/for_inference_test.dart
@@ -40,8 +40,8 @@
   Expect.type<Set<num>>({for (; false;) 1, for (; false;) 0.2});
   Expect.type<Set<int>>({for (; false;) 1, 2});
   Expect.type<Set<num>>({for (; false;) 1, 0.2});
-  Expect.type<Set<dynamic>>({if (true) ...[]});
-  Expect.type<Set<int>>({if (true) ...<int>[]});
+  Expect.type<Set<dynamic>>({for (; false;) ...[]});
+  Expect.type<Set<int>>({for (; false;) ...<int>[]});
 
   // If a nested iterable's type is dynamic, the element type is dynamic.
   Expect.type<List<dynamic>>([for (; false;) ...([] as dynamic)]);
diff --git a/tests/language_2/control_flow_collections/type_error_test.dart b/tests/language_2/control_flow_collections/type_error_test.dart
index 2656b7f..4821753 100644
--- a/tests/language_2/control_flow_collections/type_error_test.dart
+++ b/tests/language_2/control_flow_collections/type_error_test.dart
@@ -5,8 +5,6 @@
 // SharedOptions=--enable-experiment=control-flow-collections
 
 void main() {
-  Object obj = true;
-
   // Non-Boolean if condition.
   var _ = <int>[if (1) 2]; //# 00: compile-time error
   var _ = <int, int>{if (1) 2: 2}; //# 01: compile-time error
@@ -32,12 +30,12 @@
   // Wrong for-in element type.
   List<String> s = ["s"];
   var _ = <int>[for (int i in s) 1]; //# 20: compile-time error
-  var _ = <int, int>[for (int i in s) 1: 1]; //# 21: compile-time error
+  var _ = <int, int>{for (int i in s) 1: 1}; //# 21: compile-time error
   var _ = <int>{for (int i in s) 1}; //# 22: compile-time error
 
   // Wrong for declaration element type.
   var _ = <int>[for (int i = "s";;) 1]; //# 23: compile-time error
-  var _ = <int, int>[for (int i = "s";;) 1: 1]; //# 24: compile-time error
+  var _ = <int, int>{for (int i = "s";;) 1: 1}; //# 24: compile-time error
   var _ = <int>{for (int i = "s";;) 1}; //# 25: compile-time error
 
   // Wrong for body element type.
@@ -45,4 +43,16 @@
   var _ = <int, int>{for (; false;) "s": 1}; //# 27: compile-time error
   var _ = <int, int>{for (; false;) 1: "s"}; //# 28: compile-time error
   var _ = <int>{for (; false;) "s"}; //# 29: compile-time error
+
+  // Non-iterable sequence type.
+  int nonIterable = 3;
+  var _ = <int>[for (int i in nonIterable) 1]; //# 30: compile-time error
+  var _ = <int, int>{for (int i in nonIterable) 1: 1}; //# 31: compile-time error
+  var _ = <int>{for (int i in nonIterable) 1}; //# 32: compile-time error
+
+  // Object sequence type.
+  Object object = "object";
+  var _ = <int>[for (int i in object) 1]; //# 33: compile-time error
+  var _ = <int, int>{for (int i in object) 1: 1}; //# 34: compile-time error
+  var _ = <int>{for (int i in object) 1}; //# 35: compile-time error
 }