From 064824caf4df741b699b1f7c54f607e9de32a0b8 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Sun, 13 Aug 2023 16:41:03 -0500 Subject: [PATCH] Fix and increase flexibility of language version override test --- test/validator/language_version_test.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/validator/language_version_test.dart b/test/validator/language_version_test.dart index 83e6cd7b4..c0c0a2167 100644 --- a/test/validator/language_version_test.dart +++ b/test/validator/language_version_test.dart @@ -60,20 +60,25 @@ void main() { }); group('should warn if it', () { + final currentVersion = Version.parse(Platform.version.split(' ').first); + final nextLanguageVersion = + LanguageVersion(currentVersion.major, currentVersion.minor + 1) + .toString(); + test('opts in to a newer version.', () async { - final nextVersion = - Version.parse(Platform.version.split(' ').first).nextMajor; await setup( sdkConstraint: '^3.0.0', - libraryLanguageVersion: - LanguageVersion.fromVersion(nextVersion).toString(), + libraryLanguageVersion: nextLanguageVersion, ); await expectValidationWarning( 'The language version override can\'t specify a version greater than the latest known language version', ); }); test('opts in to a newer version, with non-range constraint.', () async { - await setup(sdkConstraint: '3.1.2+3', libraryLanguageVersion: '3.2'); + await setup( + sdkConstraint: '3.1.2+3', + libraryLanguageVersion: nextLanguageVersion, + ); await expectValidationWarning( 'The language version override can\'t specify a version greater than the latest known language version', );