Skip to content

Commit

Permalink
Fixes #1976. Runtime errors fixed (#1981)
Browse files Browse the repository at this point in the history
Update map pattern tests according to the new matching rules.
  • Loading branch information
sgrekhov authored Mar 31, 2023
1 parent e3b5624 commit 56e7290
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion LanguageFeatures/Patterns/if_case_A02_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ main() {
Expect.listEquals([1, 2, 4], testMap1({"key1": 1, "key2": 2}));
Expect.listEquals([1, 3, 4], testMap1({"key1": 2, "key2": 2}));
Expect.listEquals([1, 3, 4], testMap1({"key1": 1, "key2": -2}));
Expect.listEquals([1, 3, 4], testMap1({"key1": 1, "key2": 2, "key3": 3}));
Expect.listEquals([1, 2, 4], testMap1({"key1": 1, "key2": 2, "key3": 3}));
Expect.listEquals([1, 2, 4], testMap2({"key1": 1, "key2": -2}));
Expect.listEquals([1, 3, 4], testMap2({"key1": 2, "key2": -2}));
Expect.listEquals([1, 3, 4], testMap2({"key1": 1, "key2": 2}));
Expand Down
2 changes: 1 addition & 1 deletion LanguageFeatures/Patterns/if_case_A02_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ main() {
testMap1({"key1": 2, "key2": 2}));
Expect.mapEquals({"key1": 1, "key3": 3, "key4": 4},
testMap1({"key1": 1, "key2": -2}));
Expect.mapEquals({"key1": 1, "key3": 3, "key4": 4},
Expect.mapEquals({"key1": 1, "key2": 2, "key4": 4},
testMap1({"key1": 1, "key2": 2, "key3": 3}));
Expect.mapEquals({"key1": 1, "key2": 2, "key4": 4},
testMap2({"key1": 1, "key2": -2}));
Expand Down
2 changes: 1 addition & 1 deletion LanguageFeatures/Patterns/if_case_A02_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ main() {
Expect.setEquals({1, 2, 4}, testMap1({"key1": 1, "key2": 2}));
Expect.setEquals({1, 3, 4}, testMap1({"key1": 2, "key2": 2}));
Expect.setEquals({1, 3, 4}, testMap1({"key1": 1, "key2": -2}));
Expect.setEquals({1, 3, 4}, testMap1({"key1": 1, "key2": 2, "key3": 3}));
Expect.setEquals({1, 2, 4}, testMap1({"key1": 1, "key2": 2, "key3": 3}));
Expect.setEquals({1, 2, 4}, testMap2({"key1": 1, "key2": -2}));
Expect.setEquals({1, 3, 4}, testMap2({"key1": 2, "key2": -2}));
Expect.setEquals({1, 3, 4}, testMap2({"key1": 1, "key2": 2}));
Expand Down
2 changes: 1 addition & 1 deletion LanguageFeatures/Patterns/map_A01_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ main() {
final {1: a, 2: b!} = {1: 1, 2: null};
});
Expect.throws(() {
var {1: a, 2: b} = {1: "1", 2: "2", 3: "3"};
var {1: a, 2: b} = {1: "1", 3: "3"};
});
}
6 changes: 3 additions & 3 deletions LanguageFeatures/Patterns/map_A04_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ main() {

Expect.equals("a=1, b=2", test1({c1: 1, c2: 2}));
Expect.equals("default", test1({c1: 1}));
Expect.equals("default", test1({c1: 1, c2: 2, c3: 3}));
Expect.equals("a=1, b=2", test1({c1: 1, c2: 2, c3: 3}));
Expect.equals("a=1, b=2", test2({c1: 1, c2: 2}));
Expect.equals("default", test2({c1: 1}));
Expect.equals("default", test2({c1: 1, c2: 2, c3: 3}));
Expect.equals("a=1, b=2", test2({c1: 1, c2: 2, c3: 3}));
Expect.equals("a=1, b=2", test3({c1: 1, c2: 2}));
Expect.equals("default", test3({c1: 1}));
Expect.equals("default", test3({c1: 1, c2: 2, c3: 3}));
Expect.equals("a=1, b=2", test3({c1: 1, c2: 2, c3: 3}));
}
8 changes: 4 additions & 4 deletions LanguageFeatures/Patterns/pattern_context_A07_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ main() {
Expect.equals("match", testMap2({"key1": 1}));
Expect.equals("match", testMap3({"key1": 1}));
Expect.equals("match", testMap4({"key1": 1}));
Expect.equals("no match", testMap1({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap2({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap3({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap4({"key1": 1, "key2": 2}));
Expect.equals("match", testMap1({"key1": 1, "key2": 2}));
Expect.equals("match", testMap2({"key1": 1, "key2": 2}));
Expect.equals("match", testMap3({"key1": 1, "key2": 2}));
Expect.equals("match", testMap4({"key1": 1, "key2": 2}));
Expect.equals("match", testRecord1((1,)));
Expect.equals("match", testRecord2((1,)));
Expect.equals("match", testRecord3((1,)));
Expand Down
8 changes: 4 additions & 4 deletions LanguageFeatures/Patterns/pattern_context_A07_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ main() {
Expect.equals("match", testMap2({"key1": 1}));
Expect.equals("match", testMap3({"key1": 1}));
Expect.equals("match", testMap4({"key1": 1}));
Expect.equals("no match", testMap1({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap2({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap3({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap4({"key1": 1, "key2": 2}));
Expect.equals("match", testMap1({"key1": 1, "key2": 2}));
Expect.equals("match", testMap2({"key1": 1, "key2": 2}));
Expect.equals("match", testMap3({"key1": 1, "key2": 2}));
Expect.equals("match", testMap4({"key1": 1, "key2": 2}));
Expect.equals("match", testRecord1((1,)));
Expect.equals("match", testRecord2((1,)));
Expect.equals("match", testRecord3((1,)));
Expand Down
8 changes: 4 additions & 4 deletions LanguageFeatures/Patterns/pattern_context_A07_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ main() {
Expect.equals("match", testMap2({"key1": 1}));
Expect.equals("match", testMap3({"key1": 1}));
Expect.equals("match", testMap4({"key1": 1}));
Expect.equals("no match", testMap1({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap2({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap3({"key1": 1, "key2": 2}));
Expect.equals("no match", testMap4({"key1": 1, "key2": 2}));
Expect.equals("match", testMap1({"key1": 1, "key2": 2}));
Expect.equals("match", testMap2({"key1": 1, "key2": 2}));
Expect.equals("match", testMap3({"key1": 1, "key2": 2}));
Expect.equals("match", testMap4({"key1": 1, "key2": 2}));
Expect.equals("match", testRecord1((1,)));
Expect.equals("match", testRecord2((1,)));
Expect.equals("match", testRecord3((1,)));
Expand Down
6 changes: 3 additions & 3 deletions LanguageFeatures/Patterns/variable_A02_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,20 @@ main() {
Expect.equals("default", testList3(["x"]));

Expect.equals("{1: 2}", testMap1({1: 2}));
Expect.equals("default", testMap1({1: 3, 3: 4}));
Expect.equals("{1: 3}", testMap1({1: 3, 3: 4}));
Expect.equals("{2: x}", testMap1({2: "x"}));
Expect.equals("default", testMap1({3: 3}));
Expect.equals("default", testMap1({}));

Expect.equals("{1: 2}", testMap2({1: 2}));
Expect.equals("default", testMap2({1: 3, 3: 4}));
Expect.equals("{1: 3}", testMap2({1: 3, 3: 4}));
Expect.equals("{2: x}", testMap2({2: "x"}));
Expect.equals("{2: true}", testMap2({2: true}));
Expect.equals("default", testMap2({3: 3}));
Expect.equals("default", testMap2({}));

Expect.equals("{1: 2}", testMap3({1: 2}));
Expect.equals("default", testMap3({1: 3, 3: 4}));
Expect.equals("{1: 3}", testMap3({1: 3, 3: 4}));
Expect.equals("{2: x}", testMap3({2: "x"}));
Expect.equals("default", testMap3({3: 3}));
Expect.equals("default", testMap3({}));
Expand Down
18 changes: 9 additions & 9 deletions LanguageFeatures/Patterns/wildcards_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,31 @@ main() {
Expect.equals("{1: _}", test1({1: 2}));
Expect.equals("{1: _}", test1({1: 3}));
Expect.equals("{42: String _}", test1({42: ""}));
Expect.equals("default", test1({42: "", 2: "2"}));
Expect.equals("{42: String _}", test1({42: "", 2: "2"}));
Expect.equals("default", test1({2: 1}));
Expect.equals("default", test1({3: 2, 2: 1}));
Expect.equals("default", test1({}));
Expect.equals("default", test1({1: 2, 2: 1}));
Expect.equals("default", test1({1: 3, 42: ""}));
Expect.equals("{1: _}", test1({1: 2, 2: 1}));
Expect.equals("{1: _}", test1({1: 3, 42: ""}));

Expect.equals("{1: _}", test2({1: 2}));
Expect.equals("{1: _}", test2({1: 3}));
Expect.equals("{42: String _}", test2({42: ""}));
Expect.equals("default", test2({42: "", 2: "2"}));
Expect.equals("{42: String _}", test2({42: "", 2: "2"}));
Expect.equals("default", test2({2: 1}));
Expect.equals("default", test2({3: 2, 2: 1}));
Expect.equals("default", test2({}));
Expect.equals("default", test2({1: 2, 2: 1}));
Expect.equals("default", test2({1: 3, 42: ""}));
Expect.equals("{1: _}", test2({1: 2, 2: 1}));
Expect.equals("{1: _}", test2({1: 3, 42: ""}));

Expect.equals("{1: _}", test3({1: 2}));
Expect.equals("{1: _}", test3({1: 3}));
Expect.equals("{42: String _}", test3({42: ""}));
Expect.equals("default", test3({42: "", 2: "2"}));
Expect.equals("{42: String _}", test3({42: "", 2: "2"}));
Expect.equals("default", test3({2: 1}));
Expect.equals("default", test3({3: 2, 2: 1}));
Expect.equals("default", test3({}));
Expect.equals("default", test3({1: 2, 2: 1}));
Expect.equals("default", test3({1: 3, 42: ""}));
Expect.equals("{1: _}", test3({1: 2, 2: 1}));
Expect.equals("{1: _}", test3({1: 3, 42: ""}));

}

0 comments on commit 56e7290

Please sign in to comment.