From 30c4cb00b8e33f44ec32e4774eb86e88605ad1c0 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Fri, 21 Oct 2022 18:25:08 +0000 Subject: [PATCH] Add a few more tests for PART_OF_DIFFERENT_LIBRARY. Change-Id: I685874502d49e4a6b4164bb25cf449423659514a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265180 Reviewed-by: Brian Wilkerson Commit-Queue: Konstantin Shcheglov --- .../part_of_different_library_test.dart | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart b/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart index f90d50bc880..399f59ccd93 100644 --- a/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart +++ b/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart @@ -15,13 +15,44 @@ main() { @reflectiveTest class PartOfDifferentLibraryTest extends PubPackageResolutionTest { - test_name() async { - newFile('$testPackageLibPath/part.dart', "part of lub;"); + test_doesNotExist() async { await assertErrorsInCode(''' -library lib; +part 'part.dart'; +''', [ + error(CompileTimeErrorCode.URI_DOES_NOT_EXIST, 5, 11), + ]); + } + + test_doesNotExist_generated() async { + await assertErrorsInCode(''' +part 'part.g.dart'; +''', [ + error(CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED, 5, 13), + ]); + } + + test_partOfName() async { + newFile('$testPackageLibPath/part.dart', ''' +part of bar; +'''); + + await assertErrorsInCode(''' +library foo; part 'part.dart'; ''', [ error(CompileTimeErrorCode.PART_OF_DIFFERENT_LIBRARY, 18, 11), ]); } + + test_partOfUri() async { + newFile('$testPackageLibPath/part.dart', ''' +part of 'other.dart'; +'''); + + await assertErrorsInCode(''' +part 'part.dart'; +''', [ + error(CompileTimeErrorCode.PART_OF_DIFFERENT_LIBRARY, 5, 11), + ]); + } }