-
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.
Check for consistency of language version overrides between library a…
…nd parts. Change-Id: I209cbcda3d96c4e2f1f7a0352b563c886a22e687 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153702 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 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
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
111 changes: 111 additions & 0 deletions
111
pkg/analyzer/test/src/diagnostics/inconsistent_language_version_override_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,111 @@ | ||
// Copyright (c) 2020, 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/error/codes.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../../generated/test_support.dart'; | ||
import '../dart/resolution/driver_resolution.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(InconsistentLanguageVersionOverrideTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class InconsistentLanguageVersionOverrideTest extends DriverResolutionTest { | ||
CompileTimeErrorCode get _errorCode => | ||
CompileTimeErrorCode.INCONSISTENT_LANGUAGE_VERSION_OVERRIDE; | ||
|
||
test_both_different() async { | ||
await _checkLibraryAndPart( | ||
libraryContent: r''' | ||
// @dart = 2.5 | ||
part 'b.dart'; | ||
''', | ||
partContent: r''' | ||
// @dart = 2.6 | ||
part of 'a.dart'; | ||
''', | ||
partErrors: [ | ||
error(_errorCode, 0, 14), | ||
], | ||
); | ||
} | ||
|
||
test_both_same() async { | ||
await _checkLibraryAndPart( | ||
libraryContent: r''' | ||
// @dart = 2.5 | ||
part 'b.dart'; | ||
''', | ||
partContent: r''' | ||
// @dart = 2.5 | ||
part of 'a.dart'; | ||
''', | ||
partErrors: [], | ||
); | ||
} | ||
|
||
test_none() async { | ||
await _checkLibraryAndPart( | ||
libraryContent: r''' | ||
part 'b.dart'; | ||
''', | ||
partContent: r''' | ||
part of 'a.dart'; | ||
''', | ||
partErrors: [], | ||
); | ||
} | ||
|
||
test_onlyLibrary() async { | ||
await _checkLibraryAndPart( | ||
libraryContent: r''' | ||
// @dart = 2.5 | ||
part 'b.dart'; | ||
''', | ||
partContent: r''' | ||
part of 'a.dart'; | ||
''', | ||
partErrors: [ | ||
error(_errorCode, 0, 7), | ||
], | ||
); | ||
} | ||
|
||
test_onlyPart() async { | ||
await _checkLibraryAndPart( | ||
libraryContent: r''' | ||
part 'b.dart'; | ||
''', | ||
partContent: r''' | ||
// @dart = 2.5 | ||
part of 'a.dart'; | ||
''', | ||
partErrors: [ | ||
error(_errorCode, 0, 14), | ||
], | ||
); | ||
} | ||
|
||
Future<void> _checkLibraryAndPart({ | ||
@required String libraryContent, | ||
@required String partContent, | ||
@required List<ExpectedError> partErrors, | ||
}) async { | ||
var libraryPath = convertPath('/test/lib/a.dart'); | ||
var partPath = convertPath('/test/lib/b.dart'); | ||
|
||
newFile(libraryPath, content: libraryContent); | ||
|
||
newFile(partPath, content: partContent); | ||
|
||
await resolveFile(libraryPath); | ||
|
||
await assertErrorsInFile2(partPath, partErrors); | ||
} | ||
} |
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