-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since we already have support for Block in our visitors, we can extend them to support BlockExpression fairly easily. co19_2 and language_2 tests still need to be unskipped, but we can't do that until CFE respects the --enable-experiment=control-flow-collections flag. Change-Id: I48da19cc33dbf35c5ead3ea13266b01d3e0de959 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97820 Commit-Queue: Mayank Patke <fishythefish@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
- Loading branch information
1 parent
61f0f5b
commit 419243f
Showing
8 changed files
with
71 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/language_2/spread_collections/runtime_error_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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. | ||
|
||
// SharedOptions=--enable-experiment=spread-collections | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
// Typed as dynamic to also test spreading a value of type dynamic. | ||
final dynamic list = [1, 2, 3, 4]; | ||
final dynamic map = {1: 1, 2: 2, 3: 3, 4: 4}; | ||
final dynamic set = {1, 2, 3, 4}; | ||
|
||
void main() { | ||
dynamic nonIterable = 3; | ||
Expect.throwsTypeError(() => <int>[...nonIterable]); | ||
Expect.throwsTypeError(() => <int>{...nonIterable}); | ||
|
||
dynamic nonMap = 3; | ||
Expect.throwsTypeError(() => <int, int>{...nonMap}); | ||
|
||
dynamic wrongIterableType = <String>["s"]; | ||
Expect.throwsTypeError(() => <int>[...wrongIterableType]); | ||
Expect.throwsTypeError(() => <int>{...wrongIterableType}); | ||
|
||
dynamic wrongKeyType = <String, int>{"s": 1}; | ||
dynamic wrongValueType = <int, String>{1: "s"}; | ||
Expect.throwsTypeError(() => <int, int>{...wrongKeyType}); | ||
Expect.throwsTypeError(() => <int, int>{...wrongValueType}); | ||
|
||
// Mismatched collection types. | ||
Expect.throwsTypeError(() => <int>[...map]); | ||
Expect.throwsTypeError(() => <int, int>{...list}); | ||
Expect.throwsTypeError(() => <int, int>{...set}); | ||
Expect.throwsTypeError(() => <int>{...map}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters