Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 70e3e67

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Expect different errors depending on the state of the spread_collections experiment.
[email protected], [email protected] Change-Id: Ia12ea33be90ef1d390fd0a6c38fd421c317e6562 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97179 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent c85108d commit 70e3e67

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

pkg/analyzer/test/src/diagnostics/expression_in_map_test.dart

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,38 @@ main() {
1919

2020
@reflectiveTest
2121
class ExpressionInMapTest extends DriverResolutionTest {
22+
bool get isUiAsCode => analysisOptions.experimentStatus.spread_collections;
23+
2224
test_map() async {
23-
await assertErrorsInCode('''
25+
await assertErrorsInCode(
26+
'''
2427
var m = <String, int>{'a', 'b' : 2};
25-
''', [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]);
28+
''',
29+
isUiAsCode
30+
? [
31+
CompileTimeErrorCode.EXPRESSION_IN_MAP,
32+
]
33+
: [
34+
ParserErrorCode.EXPECTED_TOKEN,
35+
ParserErrorCode.MISSING_IDENTIFIER
36+
],
37+
);
2638
}
2739

2840
test_map_const() async {
29-
await assertErrorsInCode('''
41+
await assertErrorsInCode(
42+
'''
3043
var m = <String, int>{'a', 'b' : 2};
31-
''', [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]);
44+
''',
45+
isUiAsCode
46+
? [
47+
CompileTimeErrorCode.EXPRESSION_IN_MAP,
48+
]
49+
: [
50+
ParserErrorCode.EXPECTED_TOKEN,
51+
ParserErrorCode.MISSING_IDENTIFIER
52+
],
53+
);
3254
}
3355
}
3456

pkg/analyzer/test/src/diagnostics/map_entry_not_in_map_test.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,26 @@ main() {
1919

2020
@reflectiveTest
2121
class MapEntryNotInMapTest extends DriverResolutionTest {
22+
bool get isUiAsCode => analysisOptions.experimentStatus.spread_collections;
23+
2224
test_set() async {
2325
await assertErrorsInCode('''
2426
var c = <int>{1:2};
25-
''', [ParserErrorCode.UNEXPECTED_TOKEN]);
27+
''', [
28+
isUiAsCode
29+
? CompileTimeErrorCode.MAP_ENTRY_NOT_IN_MAP
30+
: ParserErrorCode.UNEXPECTED_TOKEN
31+
]);
2632
}
2733

2834
test_set_const() async {
2935
await assertErrorsInCode('''
3036
var c = const <int>{1:2};
31-
''', [ParserErrorCode.UNEXPECTED_TOKEN]);
37+
''', [
38+
isUiAsCode
39+
? CompileTimeErrorCode.MAP_ENTRY_NOT_IN_MAP
40+
: ParserErrorCode.UNEXPECTED_TOKEN
41+
]);
3242
}
3343
}
3444

0 commit comments

Comments
 (0)