forked from dart-lang/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert local library completion tests
Change-Id: I565572911964a683d203d8a40ccfd8e96845ca0b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304288 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
- Loading branch information
1 parent
041a8ef
commit 7419e25
Showing
4 changed files
with
366 additions
and
323 deletions.
There are no files selected for viewing
364 changes: 364 additions & 0 deletions
364
pkg/analysis_server/test/services/completion/dart/declaration/local_library_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,364 @@ | ||
// 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 '../../../../client/completion_driver_test.dart'; | ||
|
||
void main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(LocalLibraryTest1); | ||
defineReflectiveTests(LocalLibraryTest2); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class LocalLibraryTest1 extends AbstractCompletionDriverTest | ||
with LocalLibraryTestCases { | ||
@override | ||
TestingCompletionProtocol get protocol => TestingCompletionProtocol.version1; | ||
} | ||
|
||
@reflectiveTest | ||
class LocalLibraryTest2 extends AbstractCompletionDriverTest | ||
with LocalLibraryTestCases { | ||
@override | ||
TestingCompletionProtocol get protocol => TestingCompletionProtocol.version2; | ||
} | ||
|
||
mixin LocalLibraryTestCases on AbstractCompletionDriverTest { | ||
@override | ||
bool get includeKeywords => false; | ||
|
||
Future<void> test_partFile_Constructor() async { | ||
newFile('$testPackageLibPath/b.dart', ''' | ||
library B; | ||
int T0 = 0; | ||
F0() {} | ||
class X { | ||
X.c(); | ||
X._d0(); | ||
z0() {} | ||
} | ||
void f() { | ||
X._d0(); | ||
} | ||
'''); | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
library libA; | ||
import "b.dart"; | ||
part "test.dart"; | ||
class A0 {} | ||
var m0 = T0; | ||
'''); | ||
await computeSuggestions(''' | ||
part of libA; | ||
class B { | ||
B.bar(int x); | ||
} | ||
void f() { | ||
new ^ | ||
} | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
A0 | ||
kind: constructorInvocation | ||
'''); | ||
} | ||
|
||
Future<void> test_partFile_Constructor2() async { | ||
newFile('$testPackageLibPath/b.dart', ''' | ||
library B0; | ||
int T0 = 0; | ||
F0() {} | ||
class X { | ||
X.c(); | ||
X._d0(); | ||
z0() {} | ||
} | ||
void f() { | ||
X._d0(); | ||
} | ||
'''); | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
part of libA; | ||
class B0 {} | ||
'''); | ||
await computeSuggestions(''' | ||
library libA; | ||
import "b.dart"; | ||
part "a.dart"; | ||
class A0 { | ||
A0({String boo: 'hoo'}) {} | ||
} | ||
void f() { | ||
new ^ | ||
} | ||
var m0 = T0; | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
A0 | ||
kind: constructorInvocation | ||
B0 | ||
kind: constructorInvocation | ||
'''); | ||
} | ||
|
||
Future<void> test_partFile_extension() async { | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
part of libA; | ||
extension E0 on int {} | ||
'''); | ||
await computeSuggestions(''' | ||
library libA; | ||
part "a.dart"; | ||
void f() { | ||
^ | ||
} | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
E0 | ||
kind: extensionInvocation | ||
'''); | ||
} | ||
|
||
Future<void> test_partFile_extension_unnamed() async { | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
part of libA; | ||
extension on int {} | ||
'''); | ||
await computeSuggestions(''' | ||
library libA; | ||
part "a.dart"; | ||
void f() { | ||
^ | ||
} | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
'''); | ||
} | ||
|
||
Future<void> | ||
test_partFile_InstanceCreationExpression_assignment_filter() async { | ||
newFile('$testPackageLibPath/b.dart', ''' | ||
library B0; | ||
int T0 = 0; | ||
F0() {} | ||
class X { | ||
X.c(); | ||
X._d0(); | ||
z0() {} | ||
} | ||
void f() { | ||
X._d0(); | ||
} | ||
'''); | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
part of libA; | ||
class A0 {} | ||
class B0 extends A0 {} | ||
class C0 implements A0 {} | ||
class D0 {} | ||
'''); | ||
await computeSuggestions(''' | ||
library libA; | ||
import "b.dart"; | ||
part "a.dart"; | ||
class L0 {} | ||
void f() { | ||
A0 a; | ||
// FAIL: | ||
a = new ^ | ||
} | ||
var m0 = T0; | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
A0 | ||
kind: constructorInvocation | ||
B0 | ||
kind: constructorInvocation | ||
C0 | ||
kind: constructorInvocation | ||
D0 | ||
kind: constructorInvocation | ||
L0 | ||
kind: constructorInvocation | ||
'''); | ||
} | ||
|
||
Future<void> | ||
test_partFile_InstanceCreationExpression_variable_declaration_filter() async { | ||
newFile('$testPackageLibPath/b.dart', ''' | ||
library B0; | ||
int T0 = 0; | ||
F0() {} | ||
class X { | ||
X.c(); | ||
X._d0(); | ||
z0() {} | ||
} | ||
void f() { | ||
X._d0(); | ||
} | ||
'''); | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
part of libA; | ||
class A0 {} | ||
class B0 extends A0 {} | ||
class C0 implements A0 {} | ||
class D0 {} | ||
'''); | ||
await computeSuggestions(''' | ||
library libA; | ||
import "b.dart"; | ||
part "a.dart"; | ||
class L0 {} | ||
void f() { | ||
A0 a = new ^ | ||
} | ||
var m0 = T0; | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
A0 | ||
kind: constructorInvocation | ||
B0 | ||
kind: constructorInvocation | ||
C0 | ||
kind: constructorInvocation | ||
D0 | ||
kind: constructorInvocation | ||
L0 | ||
kind: constructorInvocation | ||
'''); | ||
} | ||
|
||
Future<void> test_partFile_TypeName() async { | ||
newFile('$testPackageLibPath/b.dart', ''' | ||
library B; | ||
int T0 = 0; | ||
F0() {} | ||
class X { | ||
X.c(); | ||
X._d0(); | ||
z0() {} | ||
} | ||
void f() { | ||
X._d0(); | ||
} | ||
'''); | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
library libA; | ||
import "b.dart"; | ||
part "test.dart"; | ||
class A0 { | ||
var a1; | ||
a2(){} | ||
} | ||
var m0 = T0; | ||
typedef t0(int blue); | ||
typedef t1 = void Function(int blue); | ||
typedef t2 = List<int>; | ||
int a0() { | ||
return 0; | ||
} | ||
'''); | ||
await computeSuggestions(''' | ||
part of libA; | ||
class B { | ||
B.bar(int x); | ||
} | ||
void f() { | ||
^ | ||
} | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
A0 | ||
kind: class | ||
A0 | ||
kind: constructorInvocation | ||
F0 | ||
kind: functionInvocation | ||
T0 | ||
kind: topLevelVariable | ||
a0 | ||
kind: functionInvocation | ||
m0 | ||
kind: topLevelVariable | ||
t0 | ||
kind: typeAlias | ||
t1 | ||
kind: typeAlias | ||
t2 | ||
kind: typeAlias | ||
'''); | ||
} | ||
|
||
Future<void> test_partFile_TypeName2() async { | ||
newFile('$testPackageLibPath/b.dart', ''' | ||
library B0; | ||
int T0 = 0; | ||
F0() {} | ||
class X { | ||
X.c(); | ||
X._d0(); | ||
z0() {} | ||
} | ||
void f() { | ||
X._d0(); | ||
} | ||
'''); | ||
newFile('$testPackageLibPath/a.dart', ''' | ||
part of libA; | ||
class B0 { | ||
var b1; | ||
b2(){} | ||
} | ||
int b0() => 0; | ||
typedef t0(int blue); | ||
var n0; | ||
'''); | ||
await computeSuggestions(''' | ||
library libA; | ||
import "b.dart"; | ||
part "a.dart"; | ||
class A0 { | ||
A0({String boo: 'hoo'}) {} | ||
} | ||
void f() { | ||
^ | ||
} | ||
var m0 = T0; | ||
'''); | ||
assertResponse(r''' | ||
suggestions | ||
A0 | ||
kind: class | ||
A0 | ||
kind: constructorInvocation | ||
B0 | ||
kind: class | ||
B0 | ||
kind: constructorInvocation | ||
F0 | ||
kind: functionInvocation | ||
T0 | ||
kind: topLevelVariable | ||
b0 | ||
kind: functionInvocation | ||
m0 | ||
kind: topLevelVariable | ||
n0 | ||
kind: topLevelVariable | ||
t0 | ||
kind: typeAlias | ||
'''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.