Skip to content

LanguageFeatures/Patterns/variable_A02_t01 #1747

@alexmarkov

Description

@alexmarkov

This test tries to match a map with 2 entries {1: 3, 3: 4} against the pattern {1: var a} which can only match maps with 1 entry:

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

String testMap1(Map m) {
switch (m) {
case {1: var a}:
a.isOdd;
Expect.throws(() {a.whatever;});
return "{1: $a}";
case {2: final b}:
b.substring(0);
Expect.throws(() {b.whatever;});
return "{2: $b}";
default:
return "default";
}
}

Metadata

Metadata

Assignees

Labels

bad-testReport tests in need of updates. When closed, the tests should be considered good

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions