Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/deprecation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ enum Deprecation {
var range = VersionRange(max: version, includeMax: true);
return {
for (var deprecation in Deprecation.values)
if (deprecation.deprecatedIn.andThen(range.allows) ?? false)
if ((deprecation.deprecatedIn.andThen(range.allows) ?? false) &&
(deprecation.obsoleteIn.andThen((v) => !range.allows(v)) ?? true))
deprecation,
};
}
Expand Down
31 changes: 31 additions & 0 deletions test/deprecations_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ library;
import 'package:test/test.dart';

import 'package:sass/sass.dart';
import 'package:pub_semver/pub_semver.dart';

void main() {
// Deprecated in all version of Dart Sass
Expand Down Expand Up @@ -151,6 +152,36 @@ void main() {
);
});
});

group('Deprecation.forVersion', () {
test('includes deprecation if not obsolete', () {
final version = Version.parse('1.91.0');
final deprecations = Deprecation.forVersion(version);

expect(
deprecations,
contains(Deprecation.mixedDecls),
reason: 'mixed-decls is obsolete in 1.92, should be fatal at 1.91',
);
});

test('excludes obsolete deprecations', () {
final version = Version.parse('1.93.0');
final deprecations = Deprecation.forVersion(version);

expect(
deprecations,
isNot(contains(Deprecation.mixedDecls)),
reason: 'mixed-decls is obsolete in 1.92, should not be fatal at 1.93',
);

expect(
deprecations,
contains(Deprecation.functionUnits),
reason: 'functionUnits is deprecated but not obsolete, should be fatal',
);
});
});
}

/// Confirms that [source] will error if [deprecation] is fatal.
Expand Down
Loading