-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add partial code tests for extension methods
Change-Id: I5886c275383302566e997cb2f7e968c446b79369 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105160 Reviewed-by: Dan Rubel <danrubel@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
- Loading branch information
1 parent
7e933ab
commit 3894b08
Showing
3 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
pkg/analyzer/test/src/fasta/recovery/partial_code/extension_declaration_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,87 @@ | ||
// Copyright (c) 2019, 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:analyzer/dart/analysis/features.dart'; | ||
import 'package:analyzer/src/dart/error/syntactic_errors.dart'; | ||
|
||
import 'partial_code_support.dart'; | ||
|
||
main() { | ||
new ExtensionDeclarationTest().buildAll(); | ||
} | ||
|
||
class ExtensionDeclarationTest extends PartialCodeTest { | ||
buildAll() { | ||
buildTests( | ||
'extension_declaration', | ||
[ | ||
new TestDescriptor( | ||
'keyword', | ||
'extension', | ||
[ | ||
ParserErrorCode.MISSING_IDENTIFIER, | ||
ParserErrorCode.EXPECTED_TOKEN, | ||
ParserErrorCode.EXPECTED_TYPE_NAME, | ||
ParserErrorCode.EXPECTED_BODY, | ||
], | ||
'extension _s_ on _s_ {}', | ||
failing: ['getter', 'functionNonVoid', 'functionVoid', 'mixin']), | ||
new TestDescriptor( | ||
'named', | ||
'extension E', | ||
[ | ||
ParserErrorCode.EXPECTED_TOKEN, | ||
ParserErrorCode.EXPECTED_TYPE_NAME, | ||
ParserErrorCode.EXPECTED_BODY, | ||
], | ||
'extension E on _s_ {}', | ||
failing: ['getter', 'functionNonVoid', 'functionVoid', 'mixin']), | ||
new TestDescriptor( | ||
'on', | ||
'extension E on', | ||
[ | ||
ParserErrorCode.EXPECTED_TYPE_NAME, | ||
ParserErrorCode.EXPECTED_BODY, | ||
], | ||
'extension E on _s_ {}', | ||
failing: ['getter', 'functionNonVoid', 'functionVoid', 'mixin']), | ||
new TestDescriptor( | ||
'extendedType', | ||
'extension E on String', | ||
[ | ||
ParserErrorCode.EXPECTED_BODY, | ||
], | ||
'extension E on String {}'), | ||
// Most of the failing tests are because the following text could be | ||
// a member of the class, so the parser adds the closing brace _after_ | ||
// the declaration that's expected to follow it. | ||
// | ||
// The notable exceptions are 'class', 'enum', 'mixin', and 'typedef'. | ||
new TestDescriptor( | ||
'partialBody', | ||
'extension E on String {', | ||
[ | ||
ScannerErrorCode.EXPECTED_TOKEN, | ||
], | ||
'extension E on String {}', | ||
failing: [ | ||
'class', | ||
'const', | ||
'enum', | ||
'final', | ||
'functionNonVoid', | ||
'functionVoid', | ||
'mixin', | ||
'getter', | ||
'setter', | ||
'typedef', | ||
'var' | ||
]), | ||
], | ||
PartialCodeTest.declarationSuffixes, | ||
featureSet: new FeatureSet.forTesting( | ||
sdkVersion: '2.3.0', | ||
additionalFeatures: [Feature.extension_methods])); | ||
} | ||
} |
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
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