mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:29:50 +00:00
Replace assertFunctionExpressionInvocation() with textual dumps.
Change-Id: I4f9d4da934a128c6413880a4bd5a8e3adf3678f7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261783 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
2ab5130eb5
commit
1ed03b3707
|
@ -76,13 +76,20 @@ f(bool Function() b) {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('b()'),
|
||||
element: null,
|
||||
typeArgumentTypes: [],
|
||||
invokeType: 'bool Function()',
|
||||
type: 'bool',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('b()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: b
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: bool Function()
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: bool Function()
|
||||
staticType: bool
|
||||
''');
|
||||
}
|
||||
|
||||
test_declaredVariableScope() async {
|
||||
|
|
|
@ -110,12 +110,19 @@ f(bool Function() b) {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('b()'),
|
||||
element: null,
|
||||
typeArgumentTypes: [],
|
||||
invokeType: 'bool Function()',
|
||||
type: 'bool',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('b()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: b
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: bool Function()
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: bool Function()
|
||||
staticType: bool
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,13 +27,29 @@ void f(A a) {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('a(0)'),
|
||||
element: findElement.method('call'),
|
||||
typeArgumentTypes: ['int'],
|
||||
invokeType: 'void Function(int)',
|
||||
type: 'void',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('a(0)');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: a
|
||||
staticElement: self::@function::f::@parameter::a
|
||||
staticType: A
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
arguments
|
||||
IntegerLiteral
|
||||
literal: 0
|
||||
parameter: ParameterMember
|
||||
base: root::@parameter::t
|
||||
substitution: {T: int}
|
||||
staticType: int
|
||||
rightParenthesis: )
|
||||
staticElement: self::@class::A::@method::call
|
||||
staticInvokeType: void Function(int)
|
||||
staticType: void
|
||||
typeArgumentTypes
|
||||
int
|
||||
''');
|
||||
}
|
||||
|
||||
test_call_infer_fromArguments_listLiteral() async {
|
||||
|
@ -49,13 +65,34 @@ main(A a) {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('a(['),
|
||||
element: findElement.method('call'),
|
||||
typeArgumentTypes: ['int'],
|
||||
invokeType: 'List<int> Function(List<int>)',
|
||||
type: 'List<int>',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('a([');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: a
|
||||
staticElement: self::@function::main::@parameter::a
|
||||
staticType: A
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
arguments
|
||||
ListLiteral
|
||||
leftBracket: [
|
||||
elements
|
||||
IntegerLiteral
|
||||
literal: 0
|
||||
staticType: int
|
||||
rightBracket: ]
|
||||
parameter: ParameterMember
|
||||
base: root::@parameter::_
|
||||
substitution: {T: int}
|
||||
staticType: List<int>
|
||||
rightParenthesis: )
|
||||
staticElement: self::@class::A::@method::call
|
||||
staticInvokeType: List<int> Function(List<int>)
|
||||
staticType: List<int>
|
||||
typeArgumentTypes
|
||||
int
|
||||
''');
|
||||
}
|
||||
|
||||
test_call_infer_fromContext() async {
|
||||
|
@ -71,13 +108,22 @@ void f(A a, int context) {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('a()'),
|
||||
element: findElement.method('call'),
|
||||
typeArgumentTypes: ['int'],
|
||||
invokeType: 'int Function()',
|
||||
type: 'int',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('a()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: a
|
||||
staticElement: self::@function::f::@parameter::a
|
||||
staticType: A
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: self::@class::A::@method::call
|
||||
staticInvokeType: int Function()
|
||||
staticType: int
|
||||
typeArgumentTypes
|
||||
int
|
||||
''');
|
||||
}
|
||||
|
||||
test_call_typeArguments() async {
|
||||
|
@ -93,13 +139,22 @@ void f(A a) {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('a<int>()'),
|
||||
element: findElement.method('call'),
|
||||
typeArgumentTypes: ['int'],
|
||||
invokeType: 'int Function()',
|
||||
type: 'int',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('a<int>()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: a
|
||||
staticElement: self::@function::f::@parameter::a
|
||||
staticType: A
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: self::@class::A::@method::call
|
||||
staticInvokeType: int Function()
|
||||
staticType: int
|
||||
typeArgumentTypes
|
||||
int
|
||||
''');
|
||||
}
|
||||
|
||||
test_never() async {
|
||||
|
@ -112,15 +167,36 @@ void f(Never x) {
|
|||
error(HintCode.DEAD_CODE, 26, 8),
|
||||
]);
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('x<int>(1 + 2)'),
|
||||
element: null,
|
||||
typeArgumentTypes: ['int'],
|
||||
invokeType: 'dynamic',
|
||||
type: 'Never',
|
||||
);
|
||||
|
||||
assertType(findNode.binary('1 + 2'), 'int');
|
||||
final node = findNode.functionExpressionInvocation('x<int>(1 + 2)');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: x
|
||||
staticElement: self::@function::f::@parameter::x
|
||||
staticType: Never
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
arguments
|
||||
BinaryExpression
|
||||
leftOperand: IntegerLiteral
|
||||
literal: 1
|
||||
staticType: int
|
||||
operator: +
|
||||
rightOperand: IntegerLiteral
|
||||
literal: 2
|
||||
parameter: dart:core::@class::num::@method::+::@parameter::other
|
||||
staticType: int
|
||||
parameter: <null>
|
||||
staticElement: dart:core::@class::num::@method::+
|
||||
staticInvokeType: num Function(num)
|
||||
staticType: int
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: dynamic
|
||||
staticType: Never
|
||||
typeArgumentTypes
|
||||
int
|
||||
''');
|
||||
}
|
||||
|
||||
test_neverQ() async {
|
||||
|
@ -132,15 +208,36 @@ void f(Never? x) {
|
|||
error(CompileTimeErrorCode.UNCHECKED_INVOCATION_OF_NULLABLE_VALUE, 21, 1),
|
||||
]);
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('x<int>(1 + 2)'),
|
||||
element: null,
|
||||
typeArgumentTypes: ['int'],
|
||||
invokeType: 'dynamic',
|
||||
type: 'dynamic',
|
||||
);
|
||||
|
||||
assertType(findNode.binary('1 + 2'), 'int');
|
||||
final node = findNode.functionExpressionInvocation('x<int>(1 + 2)');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: x
|
||||
staticElement: self::@function::f::@parameter::x
|
||||
staticType: Never?
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
arguments
|
||||
BinaryExpression
|
||||
leftOperand: IntegerLiteral
|
||||
literal: 1
|
||||
staticType: int
|
||||
operator: +
|
||||
rightOperand: IntegerLiteral
|
||||
literal: 2
|
||||
parameter: dart:core::@class::num::@method::+::@parameter::other
|
||||
staticType: int
|
||||
parameter: <null>
|
||||
staticElement: dart:core::@class::num::@method::+
|
||||
staticInvokeType: num Function(num)
|
||||
staticType: int
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: dynamic
|
||||
staticType: dynamic
|
||||
typeArgumentTypes
|
||||
int
|
||||
''');
|
||||
}
|
||||
|
||||
test_nullShorting() async {
|
||||
|
@ -156,13 +253,27 @@ class B {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('a?.foo()'),
|
||||
element: null,
|
||||
typeArgumentTypes: [],
|
||||
invokeType: 'int Function()',
|
||||
type: 'int?',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('a?.foo()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: PropertyAccess
|
||||
target: SimpleIdentifier
|
||||
token: a
|
||||
staticElement: self::@class::B::@method::bar::@parameter::a
|
||||
staticType: A?
|
||||
operator: ?.
|
||||
propertyName: SimpleIdentifier
|
||||
token: foo
|
||||
staticElement: self::@class::A::@getter::foo
|
||||
staticType: int Function()
|
||||
staticType: int Function()
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: int Function()
|
||||
staticType: int?
|
||||
''');
|
||||
}
|
||||
|
||||
test_nullShorting_extends() async {
|
||||
|
@ -178,19 +289,34 @@ class B {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('a?.foo()'),
|
||||
element: null,
|
||||
typeArgumentTypes: [],
|
||||
invokeType: 'int Function()',
|
||||
type: 'int',
|
||||
);
|
||||
|
||||
assertPropertyAccess2(
|
||||
findNode.propertyAccess('isEven'),
|
||||
element: intElement.getGetter('isEven'),
|
||||
type: 'bool?',
|
||||
);
|
||||
var node = findNode.propertyAccess('isEven');
|
||||
assertResolvedNodeText(node, r'''
|
||||
PropertyAccess
|
||||
target: FunctionExpressionInvocation
|
||||
function: PropertyAccess
|
||||
target: SimpleIdentifier
|
||||
token: a
|
||||
staticElement: self::@class::B::@method::bar::@parameter::a
|
||||
staticType: A?
|
||||
operator: ?.
|
||||
propertyName: SimpleIdentifier
|
||||
token: foo
|
||||
staticElement: self::@class::A::@getter::foo
|
||||
staticType: int Function()
|
||||
staticType: int Function()
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: int Function()
|
||||
staticType: int
|
||||
operator: .
|
||||
propertyName: SimpleIdentifier
|
||||
token: isEven
|
||||
staticElement: dart:core::@class::int::@getter::isEven
|
||||
staticType: bool
|
||||
staticType: bool?
|
||||
''');
|
||||
}
|
||||
|
||||
test_record_field_named() async {
|
||||
|
@ -313,13 +439,38 @@ main() {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('(0)'),
|
||||
element: null,
|
||||
typeArgumentTypes: [],
|
||||
invokeType: 'dynamic',
|
||||
type: 'dynamic',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('(0)');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: ParenthesizedExpression
|
||||
leftParenthesis: (
|
||||
expression: AsExpression
|
||||
expression: SimpleIdentifier
|
||||
token: main
|
||||
staticElement: self::@function::main
|
||||
staticType: dynamic Function()*
|
||||
asOperator: as
|
||||
type: NamedType
|
||||
name: SimpleIdentifier
|
||||
token: dynamic
|
||||
staticElement: dynamic@-1
|
||||
staticType: null
|
||||
type: dynamic
|
||||
staticType: dynamic
|
||||
rightParenthesis: )
|
||||
staticType: dynamic
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
arguments
|
||||
IntegerLiteral
|
||||
literal: 0
|
||||
parameter: <null>
|
||||
staticType: int*
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: dynamic
|
||||
staticType: dynamic
|
||||
''');
|
||||
}
|
||||
|
||||
test_dynamic_withTypeArguments() async {
|
||||
|
@ -329,12 +480,40 @@ main() {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('(0)'),
|
||||
element: null,
|
||||
typeArgumentTypes: ['bool', 'int'],
|
||||
invokeType: 'dynamic',
|
||||
type: 'dynamic',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('(0)');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: ParenthesizedExpression
|
||||
leftParenthesis: (
|
||||
expression: AsExpression
|
||||
expression: SimpleIdentifier
|
||||
token: main
|
||||
staticElement: self::@function::main
|
||||
staticType: dynamic Function()*
|
||||
asOperator: as
|
||||
type: NamedType
|
||||
name: SimpleIdentifier
|
||||
token: dynamic
|
||||
staticElement: dynamic@-1
|
||||
staticType: null
|
||||
type: dynamic
|
||||
staticType: dynamic
|
||||
rightParenthesis: )
|
||||
staticType: dynamic
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
arguments
|
||||
IntegerLiteral
|
||||
literal: 0
|
||||
parameter: <null>
|
||||
staticType: int*
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: dynamic
|
||||
staticType: dynamic
|
||||
typeArgumentTypes
|
||||
bool*
|
||||
int*
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,19 @@ void f(bool Function() b) {
|
|||
}
|
||||
''');
|
||||
|
||||
assertFunctionExpressionInvocation(
|
||||
findNode.functionExpressionInvocation('b()'),
|
||||
element: null,
|
||||
typeArgumentTypes: [],
|
||||
invokeType: 'bool Function()',
|
||||
type: 'bool',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('b()');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: SimpleIdentifier
|
||||
token: b
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: bool Function()
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: <null>
|
||||
staticInvokeType: bool Function()
|
||||
staticType: bool
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,19 +296,6 @@ mixin ResolutionTest implements ResourceProviderMixin {
|
|||
assertElement(node.declaredElement, element);
|
||||
}
|
||||
|
||||
void assertFunctionExpressionInvocation(
|
||||
FunctionExpressionInvocation node, {
|
||||
required ExecutableElement? element,
|
||||
required List<String> typeArgumentTypes,
|
||||
required String invokeType,
|
||||
required String type,
|
||||
}) {
|
||||
assertElement(node, element);
|
||||
assertTypeArgumentTypes(node, typeArgumentTypes);
|
||||
assertInvokeType(node, invokeType);
|
||||
assertType(node, type);
|
||||
}
|
||||
|
||||
void assertHasTestErrors() {
|
||||
expect(result.errors, isNotEmpty);
|
||||
}
|
||||
|
|
|
@ -30,14 +30,31 @@ void f() {
|
|||
2),
|
||||
]);
|
||||
|
||||
var invocation = findNode.functionExpressionInvocation('();');
|
||||
assertFunctionExpressionInvocation(
|
||||
invocation,
|
||||
element: findElement.method('call', of: 'E'),
|
||||
typeArgumentTypes: [],
|
||||
invokeType: 'void Function()',
|
||||
type: 'void',
|
||||
);
|
||||
final node = findNode.functionExpressionInvocation('();');
|
||||
assertResolvedNodeText(node, r'''
|
||||
FunctionExpressionInvocation
|
||||
function: ExtensionOverride
|
||||
extensionName: SimpleIdentifier
|
||||
token: E
|
||||
staticElement: self::@extension::E
|
||||
staticType: null
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
arguments
|
||||
IntegerLiteral
|
||||
literal: 0
|
||||
parameter: <null>
|
||||
staticType: int
|
||||
rightParenthesis: )
|
||||
extendedType: int
|
||||
staticType: null
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticElement: self::@extension::E::@method::call
|
||||
staticInvokeType: void Function()
|
||||
staticType: void
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter() async {
|
||||
|
|
Loading…
Reference in a new issue