[tests] Changing expected cast errors to type errors for collections tests
Change-Id: I0e48dba7b1612994075629c43331794bfb2d2530
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96421
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
diff --git a/tests/language_2/control_flow_collections/for_test.dart b/tests/language_2/control_flow_collections/for_test.dart
index b5bb934..6b9745d 100644
--- a/tests/language_2/control_flow_collections/for_test.dart
+++ b/tests/language_2/control_flow_collections/for_test.dart
@@ -230,9 +230,9 @@
void testRuntimeErrors() {
// Non-bool condition expression.
dynamic nonBool = 3;
- Expect.throwsCastError(() => <int>[for (; nonBool;) 1]);
- Expect.throwsCastError(() => <int, int>{for (; nonBool;) 1: 1});
- Expect.throwsCastError(() => <int>{for (; nonBool;) 1});
+ Expect.throwsTypeError(() => <int>[for (; nonBool;) 1]);
+ Expect.throwsTypeError(() => <int, int>{for (; nonBool;) 1: 1});
+ Expect.throwsTypeError(() => <int>{for (; nonBool;) 1});
// Null condition expression.
bool nullBool = null;
@@ -242,15 +242,15 @@
// Cast for variable.
dynamic nonInt = "string";
- Expect.throwsCastError(() => <int>[for (int i = nonInt; false;) 1]);
- Expect.throwsCastError(() => <int, int>{for (int i = nonInt; false;) 1: 1});
- Expect.throwsCastError(() => <int>{for (int i = nonInt; false;) 1});
+ Expect.throwsTypeError(() => <int>[for (int i = nonInt; false;) 1]);
+ Expect.throwsTypeError(() => <int, int>{for (int i = nonInt; false;) 1: 1});
+ Expect.throwsTypeError(() => <int>{for (int i = nonInt; false;) 1});
// Cast for-in variable.
dynamic nonIterable = 3;
- Expect.throwsCastError(() => <int>[for (int i in nonIterable) 1]);
- Expect.throwsCastError(() => <int, int>{for (int i in nonIterable) 1: 1});
- Expect.throwsCastError(() => <int>{for (int i in nonIterable) 1});
+ Expect.throwsTypeError(() => <int>[for (int i in nonIterable) 1]);
+ Expect.throwsTypeError(() => <int, int>{for (int i in nonIterable) 1: 1});
+ Expect.throwsTypeError(() => <int>{for (int i in nonIterable) 1});
// Null iterable.
Iterable<int> nullIterable = null;
@@ -260,10 +260,10 @@
Expect.throwsNoSuchMethodError(() => <int>{for (var i in nullIterable) 1});
// Wrong element type.
- Expect.throwsCastError(() => <int>[for (var i = 0; i < 1; i++) nonInt]);
- Expect.throwsCastError(
+ Expect.throwsTypeError(() => <int>[for (var i = 0; i < 1; i++) nonInt]);
+ Expect.throwsTypeError(
() => <int, int>{for (var i = 0; i < 1; i++) nonInt: 1});
- Expect.throwsCastError(
+ Expect.throwsTypeError(
() => <int, int>{for (var i = 0; i < 1; i++) 1: nonInt});
- Expect.throwsCastError(() => <int>{for (var i = 0; i < 1; i++) nonInt});
+ Expect.throwsTypeError(() => <int>{for (var i = 0; i < 1; i++) nonInt});
}
diff --git a/tests/language_2/control_flow_collections/if_test.dart b/tests/language_2/control_flow_collections/if_test.dart
index d420e16..9659149 100644
--- a/tests/language_2/control_flow_collections/if_test.dart
+++ b/tests/language_2/control_flow_collections/if_test.dart
@@ -232,9 +232,9 @@
void testRuntimeFailures() {
dynamic nonBool = 3;
- Expect.throwsCastError(() => <int>[if (nonBool) 1]);
- Expect.throwsCastError(() => <int, int>{if (nonBool) 1: 1});
- Expect.throwsCastError(() => <int>{if (nonBool) 1});
+ Expect.throwsTypeError(() => <int>[if (nonBool) 1]);
+ Expect.throwsTypeError(() => <int, int>{if (nonBool) 1: 1});
+ Expect.throwsTypeError(() => <int>{if (nonBool) 1});
bool nullBool = null;
Expect.throwsAssertionError(() => <int>[if (nullBool) 1]);
diff --git a/tests/language_2/spread_collections/spread_test.dart b/tests/language_2/spread_collections/spread_test.dart
index 8b23a48..182ede6 100644
--- a/tests/language_2/spread_collections/spread_test.dart
+++ b/tests/language_2/spread_collections/spread_test.dart
@@ -200,24 +200,24 @@
void testCastFailures() {
dynamic nonIterable = 3;
- Expect.throwsCastError(() => <int>[...nonIterable]);
- Expect.throwsCastError(() => <int>{...nonIterable});
+ Expect.throwsTypeError(() => <int>[...nonIterable]);
+ Expect.throwsTypeError(() => <int>{...nonIterable});
dynamic nonMap = 3;
- Expect.throwsCastError(() => <int, int>{...nonMap});
+ Expect.throwsTypeError(() => <int, int>{...nonMap});
dynamic wrongIterableType = <String>["s"];
- Expect.throwsCastError(() => <int>[...wrongIterableType]);
- Expect.throwsCastError(() => <int>{...wrongIterableType});
+ Expect.throwsTypeError(() => <int>[...wrongIterableType]);
+ Expect.throwsTypeError(() => <int>{...wrongIterableType});
dynamic wrongKeyType = <String, int>{"s": 1};
dynamic wrongValueType = <int, String>{1: "s"};
- Expect.throwsCastError(() => <int, int>{...wrongKeyType});
- Expect.throwsCastError(() => <int, int>{...wrongValueType});
+ Expect.throwsTypeError(() => <int, int>{...wrongKeyType});
+ Expect.throwsTypeError(() => <int, int>{...wrongValueType});
// Mismatched collection types.
- Expect.throwsCastError(() => <int>[...map]);
- Expect.throwsCastError(() => <int, int>{...list});
- Expect.throwsCastError(() => <int, int>{...set});
- Expect.throwsCastError(() => <int>{...map});
+ Expect.throwsTypeError(() => <int>[...map]);
+ Expect.throwsTypeError(() => <int, int>{...list});
+ Expect.throwsTypeError(() => <int, int>{...set});
+ Expect.throwsTypeError(() => <int>{...map});
}