OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library test.services.completion.contributor.dart.local_ref; | 5 library test.services.completion.contributor.dart.local_ref; |
6 | 6 |
7 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol | 7 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol |
8 show Element, ElementKind; | 8 show Element, ElementKind; |
9 import 'package:analysis_server/plugin/protocol/protocol.dart' | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' |
10 hide Element, ElementKind; | 10 hide Element, ElementKind; |
(...skipping 4579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4590 assertNotSuggested('x'); | 4590 assertNotSuggested('x'); |
4591 assertNotSuggested('e'); | 4591 assertNotSuggested('e'); |
4592 } | 4592 } |
4593 } | 4593 } |
4594 | 4594 |
4595 @reflectiveTest | 4595 @reflectiveTest |
4596 class LocalReferenceContributorTest_Driver | 4596 class LocalReferenceContributorTest_Driver |
4597 extends LocalReferenceContributorTest { | 4597 extends LocalReferenceContributorTest { |
4598 @override | 4598 @override |
4599 bool get enableNewAnalysisDriver => true; | 4599 bool get enableNewAnalysisDriver => true; |
| 4600 |
| 4601 test_ArgDefaults_function() async { |
| 4602 addTestSource(''' |
| 4603 bool hasLength(int expected, bool b) => false; |
| 4604 void main() {h^}'''); |
| 4605 await computeSuggestions(); |
| 4606 |
| 4607 assertSuggestFunction('hasLength', 'bool', |
| 4608 relevance: DART_RELEVANCE_LOCAL_FUNCTION, |
| 4609 defaultArgListString: 'expected, b'); |
| 4610 } |
| 4611 |
| 4612 test_ArgDefaults_function_none() async { |
| 4613 addTestSource(''' |
| 4614 bool hasLength() => false; |
| 4615 void main() {h^}'''); |
| 4616 await computeSuggestions(); |
| 4617 |
| 4618 assertSuggestFunction('hasLength', 'bool', |
| 4619 relevance: DART_RELEVANCE_LOCAL_FUNCTION, defaultArgListString: null); |
| 4620 } |
| 4621 |
| 4622 test_ArgDefaults_function_with_optional_positional() async { |
| 4623 _addMetaPackageSource(); |
| 4624 addTestSource(''' |
| 4625 import 'package:meta/meta.dart'; |
| 4626 |
| 4627 bool foo(int bar, [bool boo, int baz]) => false; |
| 4628 void main() {h^}'''); |
| 4629 await computeSuggestions(); |
| 4630 |
| 4631 assertSuggestFunction('foo', 'bool', |
| 4632 relevance: DART_RELEVANCE_LOCAL_FUNCTION, defaultArgListString: 'bar'); |
| 4633 } |
| 4634 |
| 4635 test_ArgDefaults_function_with_required_named() async { |
| 4636 _addMetaPackageSource(); |
| 4637 addTestSource(''' |
| 4638 import 'package:meta/meta.dart'; |
| 4639 |
| 4640 bool foo(int bar, {bool boo, @required int baz}) => false; |
| 4641 void main() {h^}'''); |
| 4642 await computeSuggestions(); |
| 4643 |
| 4644 assertSuggestFunction('foo', 'bool', |
| 4645 relevance: DART_RELEVANCE_LOCAL_FUNCTION, |
| 4646 defaultArgListString: 'bar, baz: null'); |
| 4647 } |
| 4648 |
| 4649 void _addMetaPackageSource() { |
| 4650 addPackageSource( |
| 4651 'meta', |
| 4652 'meta.dart', |
| 4653 r''' |
| 4654 library meta; |
| 4655 |
| 4656 const Required required = const Required(); |
| 4657 |
| 4658 class Required { |
| 4659 final String reason; |
| 4660 const Required([this.reason]); |
4600 } | 4661 } |
| 4662 '''); |
| 4663 } |
| 4664 } |
OLD | NEW |