Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(quality): 🐛 address wrong isDissonant condition for ImperfectQuality #449

Merged
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
6 changes: 5 additions & 1 deletion lib/src/interval/quality.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ final class ImperfectQuality extends Quality {
/// ImperfectQuality.augmented.isDissonant == true
/// ```
@override
bool get isDissonant => semitones.isNegative && semitones > 1;
bool get isDissonant {
if (this case major || minor) return false;

return true;
}

@override
// Overridden hashCode already present in the super class.
Expand Down
12 changes: 12 additions & 0 deletions test/src/interval/interval_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,34 +330,46 @@ void main() {
expect((-Interval.M7).isDissonant, isTrue);
expect((-Interval.m7).isDissonant, isTrue);
expect((-Interval.d7).isDissonant, isTrue);
expect((-Interval.A6).isDissonant, isTrue);
expect((-Interval.M6).isDissonant, isFalse);
expect((-Interval.m6).isDissonant, isFalse);
expect((-Interval.d6).isDissonant, isTrue);
expect((-Interval.A5).isDissonant, isTrue);
expect((-Interval.P5).isDissonant, isFalse);
expect((-Interval.d5).isDissonant, isTrue);
expect((-Interval.A4).isDissonant, isTrue);
expect((-Interval.P4).isDissonant, isFalse);
expect((-Interval.d4).isDissonant, isTrue);
expect((-Interval.A3).isDissonant, isTrue);
expect((-Interval.M3).isDissonant, isFalse);
expect((-Interval.m3).isDissonant, isFalse);
expect((-Interval.d3).isDissonant, isTrue);
expect((-Interval.A2).isDissonant, isTrue);
expect((-Interval.M2).isDissonant, isTrue);
expect((-Interval.m2).isDissonant, isTrue);
expect((-Interval.d2).isDissonant, isTrue);
expect((-Interval.P1).isDissonant, isFalse);
expect(Interval.d1.isDissonant, isTrue);
expect(Interval.P1.isDissonant, isFalse);
expect(Interval.A1.isDissonant, isTrue);
expect(Interval.d2.isDissonant, isTrue);
expect(Interval.m2.isDissonant, isTrue);
expect(Interval.M2.isDissonant, isTrue);
expect(Interval.A2.isDissonant, isTrue);
expect(Interval.d3.isDissonant, isTrue);
expect(Interval.m3.isDissonant, isFalse);
expect(Interval.M3.isDissonant, isFalse);
expect(Interval.A3.isDissonant, isTrue);
expect(Interval.d4.isDissonant, isTrue);
expect(Interval.P4.isDissonant, isFalse);
expect(Interval.A4.isDissonant, isTrue);
expect(Interval.d5.isDissonant, isTrue);
expect(Interval.P5.isDissonant, isFalse);
expect(Interval.A5.isDissonant, isTrue);
expect(Interval.d6.isDissonant, isTrue);
expect(Interval.m6.isDissonant, isFalse);
expect(Interval.M6.isDissonant, isFalse);
expect(Interval.A6.isDissonant, isTrue);
expect(Interval.d7.isDissonant, isTrue);
expect(Interval.m7.isDissonant, isTrue);
expect(Interval.M7.isDissonant, isTrue);
Expand Down
21 changes: 21 additions & 0 deletions test/src/interval/quality_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ void main() {
});
});

group('.isDissonant', () {
test('returns whether this Quality is dissonant', () {
expect(PerfectQuality.triplyDiminished.isDissonant, isTrue);
expect(PerfectQuality.doublyDiminished.isDissonant, isTrue);
expect(PerfectQuality.diminished.isDissonant, isTrue);
expect(PerfectQuality.perfect.isDissonant, isFalse);
expect(PerfectQuality.augmented.isDissonant, isTrue);
expect(PerfectQuality.doublyAugmented.isDissonant, isTrue);
expect(PerfectQuality.triplyAugmented.isDissonant, isTrue);

expect(ImperfectQuality.triplyDiminished.isDissonant, isTrue);
expect(ImperfectQuality.doublyDiminished.isDissonant, isTrue);
expect(ImperfectQuality.diminished.isDissonant, isTrue);
expect(ImperfectQuality.minor.isDissonant, isFalse);
expect(ImperfectQuality.major.isDissonant, isFalse);
expect(ImperfectQuality.augmented.isDissonant, isTrue);
expect(ImperfectQuality.doublyAugmented.isDissonant, isTrue);
expect(ImperfectQuality.triplyAugmented.isDissonant, isTrue);
});
});

group('.toString()', () {
test('returns a string representation of this Quality', () {
expect(PerfectQuality.triplyDiminished.toString(), 'ddd');
Expand Down