Skip to content

Commit

Permalink
Update analyzer and CFE unit tests to use && and || in patterns.
Browse files Browse the repository at this point in the history
In a follow-up CL I'll remove support for logical-and and logical-or
patterns using `&` and `|`.

Bug: dart-lang/language#2501
Change-Id: I2627cd9999ac703dd0ab63cd6be3d0d883860674
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272920
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
stereotype441 authored and Commit Queue committed Dec 1, 2022
1 parent b0c705e commit 9221f34
Show file tree
Hide file tree
Showing 31 changed files with 161 additions and 161 deletions.
4 changes: 2 additions & 2 deletions pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
Expand Up @@ -154,13 +154,13 @@ var v = a * (b + c);
var findNode = _parseStringToFindNode('''
void f(x) {
switch (x) {
case int? _ & double? _ & Object? _:
case int? _ && double? _ && Object? _:
break;
}
}
''');
_assertSource(
'int? _ & double? _ & Object? _',
'int? _ && double? _ && Object? _',
findNode.binaryPattern('Object?'),
);
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/analyzer/test/src/dart/resolution/binary_pattern_test.dart
Expand Up @@ -17,7 +17,7 @@ class BinaryPatternResolutionTest extends PubPackageResolutionTest {
test_logicalAnd_ifCase() async {
await assertNoErrorsInCode(r'''
void f(x) {
if (x case int _ & double _) {}
if (x case int _ && double _) {}
}
''');
final node = findNode.singleGuardedPattern.pattern;
Expand All @@ -31,7 +31,7 @@ BinaryPattern
staticType: null
type: int
name: _
operator: &
operator: &&
rightOperand: VariablePattern
type: NamedType
name: SimpleIdentifier
Expand All @@ -47,7 +47,7 @@ BinaryPattern
await assertNoErrorsInCode(r'''
void f(x) {
switch (x) {
case int _ & double _:
case int _ && double _:
break;
}
}
Expand All @@ -63,7 +63,7 @@ BinaryPattern
staticType: null
type: int
name: _
operator: &
operator: &&
rightOperand: VariablePattern
type: NamedType
name: SimpleIdentifier
Expand All @@ -78,7 +78,7 @@ BinaryPattern
test_logicalOr_ifCase() async {
await assertNoErrorsInCode(r'''
void f(x) {
if (x case int _ | double _) {}
if (x case int _ || double _) {}
}
''');
final node = findNode.singleGuardedPattern.pattern;
Expand All @@ -92,7 +92,7 @@ BinaryPattern
staticType: null
type: int
name: _
operator: |
operator: ||
rightOperand: VariablePattern
type: NamedType
name: SimpleIdentifier
Expand All @@ -108,7 +108,7 @@ BinaryPattern
await assertNoErrorsInCode(r'''
void f(x) {
switch (x) {
case int _ | double _:
case int _ || double _:
break;
}
}
Expand All @@ -124,7 +124,7 @@ BinaryPattern
staticType: null
type: int
name: _
operator: |
operator: ||
rightOperand: VariablePattern
type: NamedType
name: SimpleIdentifier
Expand Down

0 comments on commit 9221f34

Please sign in to comment.