dart-sdk/tests/language/control_flow_collections/for_dynamic_null_weak_test.dart
Nicholas Shahan ea03ea355c [tests] Loosen weak expectation to any throw
The current behavior is inconsistent across the backends so locking this
down in weak mode feels like a subtle breaking change. The VM currently
tries calling .iterable and throws a NoSuchMethodError. DDC throws a
TypeError.

Change-Id: Ib121a91f045a4f190be77dc57b5c216d818e0301
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144683
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-04-23 21:54:10 +00:00

24 lines
972 B
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.
// Requirements=nnbd-weak
import 'package:expect/expect.dart';
void main() {
// Null condition expression.
dynamic nullBool = null;
Expect.throwsAssertionError(() => <int>[for (; nullBool;) 1]);
Expect.throwsAssertionError(() => <int, int>{for (; nullBool;) 1: 1});
Expect.throwsAssertionError(() => <int>{for (; nullBool;) 1});
// Null iterable.
dynamic nullIterable = null;
// The current behavior is inconsistent across the backends. The VM currently
// tries calling .iterable and throws a NoSuchMethodError. DDC throws a
// TypeError.
Expect.throws(() => <int>[for (var i in nullIterable) 1]);
Expect.throws(() => <int, int>{for (var i in nullIterable) 1: 1});
Expect.throws(() => <int>{for (var i in nullIterable) 1});
}