-
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.
Merge aced052 into dev
- Loading branch information
Showing
10 changed files
with
304 additions
and
32 deletions.
There are no files selected for viewing
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
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
92 changes: 92 additions & 0 deletions
92
pkg/analyzer/test/src/dart/parser/augmentation_import_directive_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,92 @@ | ||
// Copyright (c) 2024, 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/src/dart/error/syntactic_errors.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../../diagnostics/parser_diagnostics.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(AugmentationImportDirectiveParserTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class AugmentationImportDirectiveParserTest extends ParserDiagnosticsTest { | ||
test_it() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import augment 'a.dart'; | ||
'''); | ||
parseResult.assertNoErrors(); | ||
|
||
final node = parseResult.findNode.singleAugmentationImportDirective; | ||
assertParsedNodeText(node, r''' | ||
AugmentationImportDirective | ||
importKeyword: import | ||
augmentKeyword: augment | ||
uri: SimpleStringLiteral | ||
literal: 'a.dart' | ||
semicolon: ; | ||
'''); | ||
} | ||
|
||
test_noSemicolon() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import augment 'a.dart' | ||
'''); | ||
parseResult.assertErrors([ | ||
error(ParserErrorCode.EXPECTED_TOKEN, 15, 8), | ||
]); | ||
|
||
final node = parseResult.findNode.singleAugmentationImportDirective; | ||
assertParsedNodeText(node, r''' | ||
AugmentationImportDirective | ||
importKeyword: import | ||
augmentKeyword: augment | ||
uri: SimpleStringLiteral | ||
literal: 'a.dart' | ||
semicolon: ; <synthetic> | ||
'''); | ||
} | ||
|
||
test_noUri_hasSemicolon() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import augment ; | ||
'''); | ||
parseResult.assertErrors([ | ||
error(ParserErrorCode.EXPECTED_STRING_LITERAL, 15, 1), | ||
]); | ||
|
||
final node = parseResult.findNode.singleAugmentationImportDirective; | ||
assertParsedNodeText(node, r''' | ||
AugmentationImportDirective | ||
importKeyword: import | ||
augmentKeyword: augment | ||
uri: SimpleStringLiteral | ||
literal: "" <synthetic> | ||
semicolon: ; | ||
'''); | ||
} | ||
|
||
test_noUri_noSemicolon() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import augment | ||
'''); | ||
parseResult.assertErrors([ | ||
error(ParserErrorCode.EXPECTED_TOKEN, 7, 7), | ||
error(ParserErrorCode.EXPECTED_STRING_LITERAL, 15, 0), | ||
]); | ||
|
||
final node = parseResult.findNode.singleAugmentationImportDirective; | ||
assertParsedNodeText(node, r''' | ||
AugmentationImportDirective | ||
importKeyword: import | ||
augmentKeyword: augment | ||
uri: SimpleStringLiteral | ||
literal: "" <synthetic> | ||
semicolon: ; <synthetic> | ||
'''); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
pkg/analyzer/test/src/dart/parser/import_directive_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,88 @@ | ||
// Copyright (c) 2024, 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/src/dart/error/syntactic_errors.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../../diagnostics/parser_diagnostics.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(ImportDirectiveParserTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class ImportDirectiveParserTest extends ParserDiagnosticsTest { | ||
test_it() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import 'a.dart'; | ||
'''); | ||
parseResult.assertNoErrors(); | ||
|
||
final node = parseResult.findNode.singleImportDirective; | ||
assertParsedNodeText(node, r''' | ||
ImportDirective | ||
importKeyword: import | ||
uri: SimpleStringLiteral | ||
literal: 'a.dart' | ||
semicolon: ; | ||
'''); | ||
} | ||
|
||
test_noSemicolon() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import 'a.dart' | ||
'''); | ||
parseResult.assertErrors([ | ||
error(ParserErrorCode.EXPECTED_TOKEN, 7, 8), | ||
]); | ||
|
||
final node = parseResult.findNode.singleImportDirective; | ||
assertParsedNodeText(node, r''' | ||
ImportDirective | ||
importKeyword: import | ||
uri: SimpleStringLiteral | ||
literal: 'a.dart' | ||
semicolon: ; <synthetic> | ||
'''); | ||
} | ||
|
||
test_noUri_hasSemicolon() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import ; | ||
'''); | ||
parseResult.assertErrors([ | ||
error(ParserErrorCode.EXPECTED_STRING_LITERAL, 7, 1), | ||
]); | ||
|
||
final node = parseResult.findNode.singleImportDirective; | ||
assertParsedNodeText(node, r''' | ||
ImportDirective | ||
importKeyword: import | ||
uri: SimpleStringLiteral | ||
literal: "" <synthetic> | ||
semicolon: ; | ||
'''); | ||
} | ||
|
||
test_noUri_noSemicolon() { | ||
final parseResult = parseStringWithErrors(r''' | ||
import | ||
'''); | ||
parseResult.assertErrors([ | ||
error(ParserErrorCode.EXPECTED_TOKEN, 0, 6), | ||
error(ParserErrorCode.EXPECTED_STRING_LITERAL, 7, 0), | ||
]); | ||
|
||
final node = parseResult.findNode.singleImportDirective; | ||
assertParsedNodeText(node, r''' | ||
ImportDirective | ||
importKeyword: import | ||
uri: SimpleStringLiteral | ||
literal: "" <synthetic> | ||
semicolon: ; <synthetic> | ||
'''); | ||
} | ||
} |
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
Oops, something went wrong.