mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:01:20 +00:00
Add tests for AwaitExpression and unresolved identifiers.
I saw that the linter roll reported a strange InvalidType related error. So, I wanted to check if this is something I can reproduce. I cannot, but the tests might be useful anyway. Change-Id: I21138685c4fee028f0620d3fcfa3a221a304c951 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304325 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
17c626f8b3
commit
e1f153f7a2
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_collection_resolution.dart';
|
||||
|
@ -84,6 +85,92 @@ AwaitExpression
|
|||
staticType: int
|
||||
staticType: int
|
||||
staticType: int
|
||||
''');
|
||||
}
|
||||
|
||||
test_unresolved_identifier() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f() async {
|
||||
await unresolved;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.UNDEFINED_IDENTIFIER, 25, 10),
|
||||
]);
|
||||
|
||||
final node = findNode.singleAwaitExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AwaitExpression
|
||||
awaitKeyword: await
|
||||
expression: SimpleIdentifier
|
||||
token: unresolved
|
||||
staticElement: <null>
|
||||
staticType: InvalidType
|
||||
staticType: InvalidType
|
||||
''');
|
||||
}
|
||||
|
||||
test_unresolved_prefixedIdentifier() async {
|
||||
await assertErrorsInCode(r'''
|
||||
import 'dart:math' as prefix;
|
||||
|
||||
void f() async {
|
||||
await prefix.unresolved;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.UNDEFINED_PREFIXED_NAME, 63, 10),
|
||||
]);
|
||||
|
||||
final node = findNode.singleAwaitExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AwaitExpression
|
||||
awaitKeyword: await
|
||||
expression: PrefixedIdentifier
|
||||
prefix: SimpleIdentifier
|
||||
token: prefix
|
||||
staticElement: self::@prefix::prefix
|
||||
staticType: null
|
||||
period: .
|
||||
identifier: SimpleIdentifier
|
||||
token: unresolved
|
||||
staticElement: <null>
|
||||
staticType: InvalidType
|
||||
staticElement: <null>
|
||||
staticType: InvalidType
|
||||
staticType: InvalidType
|
||||
''');
|
||||
}
|
||||
|
||||
test_unresolved_propertyAccess() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f() async {
|
||||
await 0.isEven.unresolved;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.UNDEFINED_GETTER, 34, 10),
|
||||
]);
|
||||
|
||||
final node = findNode.singleAwaitExpression;
|
||||
assertResolvedNodeText(node, r'''
|
||||
AwaitExpression
|
||||
awaitKeyword: await
|
||||
expression: PropertyAccess
|
||||
target: PropertyAccess
|
||||
target: IntegerLiteral
|
||||
literal: 0
|
||||
staticType: int
|
||||
operator: .
|
||||
propertyName: SimpleIdentifier
|
||||
token: isEven
|
||||
staticElement: dart:core::@class::int::@getter::isEven
|
||||
staticType: bool
|
||||
staticType: bool
|
||||
operator: .
|
||||
propertyName: SimpleIdentifier
|
||||
token: unresolved
|
||||
staticElement: <null>
|
||||
staticType: InvalidType
|
||||
staticType: InvalidType
|
||||
staticType: InvalidType
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue