blob: b71f8ec29adf4a99ec94f498c2cc24a61380d9b6 [file] [log] [blame]
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(IsExpressionResolutionTest);
});
}
@reflectiveTest
class IsExpressionResolutionTest extends PubPackageResolutionTest {
test_expression_switchExpression() async {
await assertNoErrorsInCode('''
void f(Object? x) {
(switch (x) {
_ => 0,
} is double);
}
''');
var node = findNode.isExpression('is double');
assertResolvedNodeText(node, r'''
IsExpression
expression: SwitchExpression
switchKeyword: switch
leftParenthesis: (
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
rightParenthesis: )
leftBracket: {
cases
SwitchExpressionCase
guardedPattern: GuardedPattern
pattern: WildcardPattern
name: _
matchedValueType: Object?
arrow: =>
expression: IntegerLiteral
literal: 0
staticType: int
rightBracket: }
staticType: int
isOperator: is
type: NamedType
name: SimpleIdentifier
token: double
staticElement: dart:core::@class::double
staticType: null
type: double
staticType: bool
''');
}
}