Skip to content

Commit

Permalink
[wildcards] type definition tests
Browse files Browse the repository at this point in the history
See: #55681

Change-Id: Ib264ddfa2937e6c7fe1a0189a79255b137426bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381944
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
  • Loading branch information
pq authored and Commit Queue committed Aug 23, 2024
1 parent 2df7d1a commit f8471fb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkg/analysis_server/test/lsp/type_definition_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ const a = [!12^.3!];
_expectSdkCoreType(result, 'double');
}

Future<void> test_doubleLiteral_wildcard() async {
var code = TestCode.parse('''
const _ = [!12^.3!];
''');

var result = await _getResult(code);
expect(result.originSelectionRange, code.range.range);
_expectSdkCoreType(result, 'double');
}

Future<void> test_getter() async {
var code = TestCode.parse('''
class A {
Expand Down Expand Up @@ -143,6 +153,18 @@ void f(String a) {
_expectSdkCoreType(result, 'String');
}

Future<void> test_parameter_wildcard() async {
var code = TestCode.parse('''
void f(String _) {
f([!'te^st'!]);
}
''');

var result = await _getResult(code);
expect(result.originSelectionRange, code.range.range);
_expectSdkCoreType(result, 'String');
}

Future<void> test_parameterName() async {
var code = TestCode.parse('''
void f({String? a}) {
Expand Down Expand Up @@ -192,6 +214,19 @@ const a = [!'te^st string'!];
_expectSdkCoreType(result, 'String');
}

Future<void> test_type_underscore() async {
var code = TestCode.parse('''
class _ { }
_ a = _();
_ f() => [!^a!];
''');

var result = await _getResult(code);
expect(result.targetUri, mainFileUri);
expect(result.targetRange, rangeOfString(code, 'class _ { }'));
}

Future<void> test_unopenedFile() async {
var code = TestCode.parse('''
const a = [!'^'!];
Expand Down

0 comments on commit f8471fb

Please sign in to comment.