Skip to content

Commit 56e7290

Browse files
authored
Fixes #1976. Runtime errors fixed (#1981)
Update map pattern tests according to the new matching rules.
1 parent e3b5624 commit 56e7290

10 files changed

+31
-31
lines changed

LanguageFeatures/Patterns/if_case_A02_t01.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ main() {
175175
Expect.listEquals([1, 2, 4], testMap1({"key1": 1, "key2": 2}));
176176
Expect.listEquals([1, 3, 4], testMap1({"key1": 2, "key2": 2}));
177177
Expect.listEquals([1, 3, 4], testMap1({"key1": 1, "key2": -2}));
178-
Expect.listEquals([1, 3, 4], testMap1({"key1": 1, "key2": 2, "key3": 3}));
178+
Expect.listEquals([1, 2, 4], testMap1({"key1": 1, "key2": 2, "key3": 3}));
179179
Expect.listEquals([1, 2, 4], testMap2({"key1": 1, "key2": -2}));
180180
Expect.listEquals([1, 3, 4], testMap2({"key1": 2, "key2": -2}));
181181
Expect.listEquals([1, 3, 4], testMap2({"key1": 1, "key2": 2}));

LanguageFeatures/Patterns/if_case_A02_t02.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ main() {
274274
testMap1({"key1": 2, "key2": 2}));
275275
Expect.mapEquals({"key1": 1, "key3": 3, "key4": 4},
276276
testMap1({"key1": 1, "key2": -2}));
277-
Expect.mapEquals({"key1": 1, "key3": 3, "key4": 4},
277+
Expect.mapEquals({"key1": 1, "key2": 2, "key4": 4},
278278
testMap1({"key1": 1, "key2": 2, "key3": 3}));
279279
Expect.mapEquals({"key1": 1, "key2": 2, "key4": 4},
280280
testMap2({"key1": 1, "key2": -2}));

LanguageFeatures/Patterns/if_case_A02_t03.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ main() {
249249
Expect.setEquals({1, 2, 4}, testMap1({"key1": 1, "key2": 2}));
250250
Expect.setEquals({1, 3, 4}, testMap1({"key1": 2, "key2": 2}));
251251
Expect.setEquals({1, 3, 4}, testMap1({"key1": 1, "key2": -2}));
252-
Expect.setEquals({1, 3, 4}, testMap1({"key1": 1, "key2": 2, "key3": 3}));
252+
Expect.setEquals({1, 2, 4}, testMap1({"key1": 1, "key2": 2, "key3": 3}));
253253
Expect.setEquals({1, 2, 4}, testMap2({"key1": 1, "key2": -2}));
254254
Expect.setEquals({1, 3, 4}, testMap2({"key1": 2, "key2": -2}));
255255
Expect.setEquals({1, 3, 4}, testMap2({"key1": 1, "key2": 2}));

LanguageFeatures/Patterns/map_A01_t04.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ main() {
5454
final {1: a, 2: b!} = {1: 1, 2: null};
5555
});
5656
Expect.throws(() {
57-
var {1: a, 2: b} = {1: "1", 2: "2", 3: "3"};
57+
var {1: a, 2: b} = {1: "1", 3: "3"};
5858
});
5959
}

LanguageFeatures/Patterns/map_A04_t02.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ main() {
8383

8484
Expect.equals("a=1, b=2", test1({c1: 1, c2: 2}));
8585
Expect.equals("default", test1({c1: 1}));
86-
Expect.equals("default", test1({c1: 1, c2: 2, c3: 3}));
86+
Expect.equals("a=1, b=2", test1({c1: 1, c2: 2, c3: 3}));
8787
Expect.equals("a=1, b=2", test2({c1: 1, c2: 2}));
8888
Expect.equals("default", test2({c1: 1}));
89-
Expect.equals("default", test2({c1: 1, c2: 2, c3: 3}));
89+
Expect.equals("a=1, b=2", test2({c1: 1, c2: 2, c3: 3}));
9090
Expect.equals("a=1, b=2", test3({c1: 1, c2: 2}));
9191
Expect.equals("default", test3({c1: 1}));
92-
Expect.equals("default", test3({c1: 1, c2: 2, c3: 3}));
92+
Expect.equals("a=1, b=2", test3({c1: 1, c2: 2, c3: 3}));
9393
}

LanguageFeatures/Patterns/pattern_context_A07_t01.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ main() {
465465
Expect.equals("match", testMap2({"key1": 1}));
466466
Expect.equals("match", testMap3({"key1": 1}));
467467
Expect.equals("match", testMap4({"key1": 1}));
468-
Expect.equals("no match", testMap1({"key1": 1, "key2": 2}));
469-
Expect.equals("no match", testMap2({"key1": 1, "key2": 2}));
470-
Expect.equals("no match", testMap3({"key1": 1, "key2": 2}));
471-
Expect.equals("no match", testMap4({"key1": 1, "key2": 2}));
468+
Expect.equals("match", testMap1({"key1": 1, "key2": 2}));
469+
Expect.equals("match", testMap2({"key1": 1, "key2": 2}));
470+
Expect.equals("match", testMap3({"key1": 1, "key2": 2}));
471+
Expect.equals("match", testMap4({"key1": 1, "key2": 2}));
472472
Expect.equals("match", testRecord1((1,)));
473473
Expect.equals("match", testRecord2((1,)));
474474
Expect.equals("match", testRecord3((1,)));

LanguageFeatures/Patterns/pattern_context_A07_t02.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ main() {
333333
Expect.equals("match", testMap2({"key1": 1}));
334334
Expect.equals("match", testMap3({"key1": 1}));
335335
Expect.equals("match", testMap4({"key1": 1}));
336-
Expect.equals("no match", testMap1({"key1": 1, "key2": 2}));
337-
Expect.equals("no match", testMap2({"key1": 1, "key2": 2}));
338-
Expect.equals("no match", testMap3({"key1": 1, "key2": 2}));
339-
Expect.equals("no match", testMap4({"key1": 1, "key2": 2}));
336+
Expect.equals("match", testMap1({"key1": 1, "key2": 2}));
337+
Expect.equals("match", testMap2({"key1": 1, "key2": 2}));
338+
Expect.equals("match", testMap3({"key1": 1, "key2": 2}));
339+
Expect.equals("match", testMap4({"key1": 1, "key2": 2}));
340340
Expect.equals("match", testRecord1((1,)));
341341
Expect.equals("match", testRecord2((1,)));
342342
Expect.equals("match", testRecord3((1,)));

LanguageFeatures/Patterns/pattern_context_A07_t03.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,10 @@ main() {
377377
Expect.equals("match", testMap2({"key1": 1}));
378378
Expect.equals("match", testMap3({"key1": 1}));
379379
Expect.equals("match", testMap4({"key1": 1}));
380-
Expect.equals("no match", testMap1({"key1": 1, "key2": 2}));
381-
Expect.equals("no match", testMap2({"key1": 1, "key2": 2}));
382-
Expect.equals("no match", testMap3({"key1": 1, "key2": 2}));
383-
Expect.equals("no match", testMap4({"key1": 1, "key2": 2}));
380+
Expect.equals("match", testMap1({"key1": 1, "key2": 2}));
381+
Expect.equals("match", testMap2({"key1": 1, "key2": 2}));
382+
Expect.equals("match", testMap3({"key1": 1, "key2": 2}));
383+
Expect.equals("match", testMap4({"key1": 1, "key2": 2}));
384384
Expect.equals("match", testRecord1((1,)));
385385
Expect.equals("match", testRecord2((1,)));
386386
Expect.equals("match", testRecord3((1,)));

LanguageFeatures/Patterns/variable_A02_t01.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,20 @@ main() {
209209
Expect.equals("default", testList3(["x"]));
210210

211211
Expect.equals("{1: 2}", testMap1({1: 2}));
212-
Expect.equals("default", testMap1({1: 3, 3: 4}));
212+
Expect.equals("{1: 3}", testMap1({1: 3, 3: 4}));
213213
Expect.equals("{2: x}", testMap1({2: "x"}));
214214
Expect.equals("default", testMap1({3: 3}));
215215
Expect.equals("default", testMap1({}));
216216

217217
Expect.equals("{1: 2}", testMap2({1: 2}));
218-
Expect.equals("default", testMap2({1: 3, 3: 4}));
218+
Expect.equals("{1: 3}", testMap2({1: 3, 3: 4}));
219219
Expect.equals("{2: x}", testMap2({2: "x"}));
220220
Expect.equals("{2: true}", testMap2({2: true}));
221221
Expect.equals("default", testMap2({3: 3}));
222222
Expect.equals("default", testMap2({}));
223223

224224
Expect.equals("{1: 2}", testMap3({1: 2}));
225-
Expect.equals("default", testMap3({1: 3, 3: 4}));
225+
Expect.equals("{1: 3}", testMap3({1: 3, 3: 4}));
226226
Expect.equals("{2: x}", testMap3({2: "x"}));
227227
Expect.equals("default", testMap3({3: 3}));
228228
Expect.equals("default", testMap3({}));

LanguageFeatures/Patterns/wildcards_A01_t02.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,31 @@ main() {
7474
Expect.equals("{1: _}", test1({1: 2}));
7575
Expect.equals("{1: _}", test1({1: 3}));
7676
Expect.equals("{42: String _}", test1({42: ""}));
77-
Expect.equals("default", test1({42: "", 2: "2"}));
77+
Expect.equals("{42: String _}", test1({42: "", 2: "2"}));
7878
Expect.equals("default", test1({2: 1}));
7979
Expect.equals("default", test1({3: 2, 2: 1}));
8080
Expect.equals("default", test1({}));
81-
Expect.equals("default", test1({1: 2, 2: 1}));
82-
Expect.equals("default", test1({1: 3, 42: ""}));
81+
Expect.equals("{1: _}", test1({1: 2, 2: 1}));
82+
Expect.equals("{1: _}", test1({1: 3, 42: ""}));
8383

8484
Expect.equals("{1: _}", test2({1: 2}));
8585
Expect.equals("{1: _}", test2({1: 3}));
8686
Expect.equals("{42: String _}", test2({42: ""}));
87-
Expect.equals("default", test2({42: "", 2: "2"}));
87+
Expect.equals("{42: String _}", test2({42: "", 2: "2"}));
8888
Expect.equals("default", test2({2: 1}));
8989
Expect.equals("default", test2({3: 2, 2: 1}));
9090
Expect.equals("default", test2({}));
91-
Expect.equals("default", test2({1: 2, 2: 1}));
92-
Expect.equals("default", test2({1: 3, 42: ""}));
91+
Expect.equals("{1: _}", test2({1: 2, 2: 1}));
92+
Expect.equals("{1: _}", test2({1: 3, 42: ""}));
9393

9494
Expect.equals("{1: _}", test3({1: 2}));
9595
Expect.equals("{1: _}", test3({1: 3}));
9696
Expect.equals("{42: String _}", test3({42: ""}));
97-
Expect.equals("default", test3({42: "", 2: "2"}));
97+
Expect.equals("{42: String _}", test3({42: "", 2: "2"}));
9898
Expect.equals("default", test3({2: 1}));
9999
Expect.equals("default", test3({3: 2, 2: 1}));
100100
Expect.equals("default", test3({}));
101-
Expect.equals("default", test3({1: 2, 2: 1}));
102-
Expect.equals("default", test3({1: 3, 42: ""}));
101+
Expect.equals("{1: _}", test3({1: 2, 2: 1}));
102+
Expect.equals("{1: _}", test3({1: 3, 42: ""}));
103103

104104
}

0 commit comments

Comments
 (0)