mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:56:57 +00:00
64b0ce5b58
The features control-flow-collections and spread-collections have been shipped and it is no longer necessary for tests to explicitly opt into them. Change-Id: I074b91d12e4e485ee4a64147947bb1113899ecdc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104780 Auto-Submit: Kevin Millikin <kmillikin@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Commit-Queue: Kevin Millikin <kmillikin@google.com>
28 lines
1.1 KiB
Dart
28 lines
1.1 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
void main() {
|
|
// Cast for variable.
|
|
dynamic nonInt = "string";
|
|
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.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});
|
|
|
|
// Wrong element type.
|
|
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.throwsTypeError(
|
|
() => <int, int>{for (var i = 0; i < 1; i++) 1: nonInt});
|
|
Expect.throwsTypeError(() => <int>{for (var i = 0; i < 1; i++) nonInt});
|
|
}
|