|
| 1 | +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 6 | +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 7 | + |
| 8 | +import 'completion_relevance.dart'; |
| 9 | + |
| 10 | +void main() { |
| 11 | + defineReflectiveSuite(() { |
| 12 | + defineReflectiveTests(IsNoSuchMethodTest); |
| 13 | + }); |
| 14 | +} |
| 15 | + |
| 16 | +@reflectiveTest |
| 17 | +class IsNoSuchMethodTest extends CompletionRelevanceTest { |
| 18 | + Future<void> test_notSuper() async { |
| 19 | + await addTestFile(''' |
| 20 | +void foo(Object o) { |
| 21 | + o.^; |
| 22 | +} |
| 23 | +'''); |
| 24 | + |
| 25 | + var toStringSuggestion = suggestionWith( |
| 26 | + completion: 'toString', |
| 27 | + element: ElementKind.METHOD, |
| 28 | + kind: CompletionSuggestionKind.INVOCATION); |
| 29 | + |
| 30 | + var noSuchMethodSuggestion = suggestionWith( |
| 31 | + completion: 'noSuchMethod', |
| 32 | + element: ElementKind.METHOD, |
| 33 | + kind: CompletionSuggestionKind.INVOCATION); |
| 34 | + |
| 35 | + assertOrder([toStringSuggestion, noSuchMethodSuggestion]); |
| 36 | + } |
| 37 | + |
| 38 | + Future<void> test_super() async { |
| 39 | + await addTestFile(''' |
| 40 | +class C { |
| 41 | + dynamic noSuchMethod(Invocation i) => super.^; |
| 42 | +} |
| 43 | +'''); |
| 44 | + |
| 45 | + var toStringSuggestion = suggestionWith( |
| 46 | + completion: 'toString', |
| 47 | + element: ElementKind.METHOD, |
| 48 | + kind: CompletionSuggestionKind.INVOCATION); |
| 49 | + |
| 50 | + var noSuchMethodSuggestion = suggestionWith( |
| 51 | + completion: 'noSuchMethod', |
| 52 | + element: ElementKind.METHOD, |
| 53 | + kind: CompletionSuggestionKind.INVOCATION); |
| 54 | + |
| 55 | + assertOrder([noSuchMethodSuggestion, toStringSuggestion]); |
| 56 | + } |
| 57 | +} |
0 commit comments