Skip to content

Commit 5eeacf2

Browse files
committed
Merge branch 'main' into feat/package-config-language-version-relational
2 parents c1e933d + b51f39d commit 5eeacf2

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

pkgs/package_config/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
- Add relational operators to `LanguageVersion` with extension methods
44
exported under `LanguageVersionRelationalOperators`.
55

6+
- Include correct parameter names in errors when validating
7+
the `major` and `minor` versions in the `LanguageVersion.new` constructor.
8+
69
## 2.1.1
710

811
- Require Dart 3.4

pkgs/package_config/lib/src/package_config.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,15 @@ abstract class Package {
301301
abstract class LanguageVersion implements Comparable<LanguageVersion> {
302302
/// The maximal value allowed by [major] and [minor] values;
303303
static const int maxValue = 0x7FFFFFFF;
304+
305+
/// Constructs a [LanguageVersion] with the specified
306+
/// [major] and [minor] version numbers.
307+
///
308+
/// Both [major] and [minor] must be greater than or equal to 0
309+
/// and less than or equal to [maxValue].
304310
factory LanguageVersion(int major, int minor) {
305311
RangeError.checkValueInInterval(major, 0, maxValue, 'major');
306-
RangeError.checkValueInInterval(minor, 0, maxValue, 'major');
312+
RangeError.checkValueInInterval(minor, 0, maxValue, 'minor');
307313
return SimpleLanguageVersion(major, minor, null);
308314
}
309315

pkgs/package_config/test/package_config_impl_test.dart

+14-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,23 @@ void main() {
2020
});
2121

2222
test('negative major', () {
23-
expect(() => LanguageVersion(-1, 1), throwsArgumentError);
23+
expect(
24+
() => LanguageVersion(-1, 1),
25+
throwsA(isA<RangeError>().having(
26+
(e) => e.name,
27+
'message',
28+
contains('major'),
29+
)));
2430
});
2531

2632
test('negative minor', () {
27-
expect(() => LanguageVersion(1, -1), throwsArgumentError);
33+
expect(
34+
() => LanguageVersion(1, -1),
35+
throwsA(isA<RangeError>().having(
36+
(e) => e.name,
37+
'message',
38+
contains('minor'),
39+
)));
2840
});
2941

3042
test('minimal parse', () {

0 commit comments

Comments
 (0)