diff --git a/pkgs/package_config/CHANGELOG.md b/pkgs/package_config/CHANGELOG.md index 101a0fe76..2c070c25f 100644 --- a/pkgs/package_config/CHANGELOG.md +++ b/pkgs/package_config/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.1.2-wip + +- Include correct parameter names in errors when validating + the `major` and `minor` versions in the `LanguageVersion.new` constructor. + ## 2.1.1 - Require Dart 3.4 diff --git a/pkgs/package_config/lib/src/package_config.dart b/pkgs/package_config/lib/src/package_config.dart index 155dfc539..1f7562ae2 100644 --- a/pkgs/package_config/lib/src/package_config.dart +++ b/pkgs/package_config/lib/src/package_config.dart @@ -301,9 +301,15 @@ abstract class Package { abstract class LanguageVersion implements Comparable { /// The maximal value allowed by [major] and [minor] values; static const int maxValue = 0x7FFFFFFF; + + /// Constructs a [LanguageVersion] with the specified + /// [major] and [minor] version numbers. + /// + /// Both [major] and [minor] must be greater than or equal to 0 + /// and less than or equal to [maxValue]. factory LanguageVersion(int major, int minor) { RangeError.checkValueInInterval(major, 0, maxValue, 'major'); - RangeError.checkValueInInterval(minor, 0, maxValue, 'major'); + RangeError.checkValueInInterval(minor, 0, maxValue, 'minor'); return SimpleLanguageVersion(major, minor, null); } diff --git a/pkgs/package_config/pubspec.yaml b/pkgs/package_config/pubspec.yaml index 634d71050..1ac63bfc8 100644 --- a/pkgs/package_config/pubspec.yaml +++ b/pkgs/package_config/pubspec.yaml @@ -1,5 +1,5 @@ name: package_config -version: 2.1.1 +version: 2.1.2-wip description: Support for reading and writing Dart Package Configuration files. repository: https://github.com/dart-lang/tools/tree/main/pkgs/package_config issue_tracker: https://github.com/dart-lang/tools/labels/package%3Apackage_config diff --git a/pkgs/package_config/test/package_config_impl_test.dart b/pkgs/package_config/test/package_config_impl_test.dart index 0f399636f..fe1c98c90 100644 --- a/pkgs/package_config/test/package_config_impl_test.dart +++ b/pkgs/package_config/test/package_config_impl_test.dart @@ -20,11 +20,23 @@ void main() { }); test('negative major', () { - expect(() => LanguageVersion(-1, 1), throwsArgumentError); + expect( + () => LanguageVersion(-1, 1), + throwsA(isA().having( + (e) => e.name, + 'message', + contains('major'), + ))); }); test('negative minor', () { - expect(() => LanguageVersion(1, -1), throwsArgumentError); + expect( + () => LanguageVersion(1, -1), + throwsA(isA().having( + (e) => e.name, + 'message', + contains('minor'), + ))); }); test('minimal parse', () {