Skip to content

Commit

Permalink
chore: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodev01 committed May 11, 2023
1 parent e68bb9b commit e994c00
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 233 deletions.
4 changes: 2 additions & 2 deletions example/bin/fraction_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:io';

import 'package:fraction_example/fraction_example.dart';

/// The app's main entrypoint.
/// The application's main entrypoint.
void main() {
stdout.encoding = utf8;

Expand Down Expand Up @@ -38,7 +38,7 @@ void main() {
}

// To keep the console 'awake'. This is very useful on Windows!
stdout.write('Press return to exit...');
stdout.write('Press any key to exit...');

// ignore: avoid-ignoring-return-values
stdin.readLineSync();
Expand Down
2 changes: 1 addition & 1 deletion example/lib/src/analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:fraction/fraction.dart';
/// This base class is used to analyze an [input] string.
///
/// The [analyze] method tries to convert [input] into a [Fraction] or
/// [MixedFraction] object. It prints various properties of the fraction.
/// [MixedFraction] object and prints various properties to the console.
abstract base class RationalAnalyzer {
/// The fraction or mixed fraction input.
final String input;
Expand Down
13 changes: 0 additions & 13 deletions example/lib/src/analyzer/analyzer.dart

This file was deleted.

32 changes: 0 additions & 32 deletions example/lib/src/analyzer/fraction_analyzer.dart

This file was deleted.

29 changes: 0 additions & 29 deletions example/lib/src/analyzer/mixed_fraction_analyzer.dart

This file was deleted.

49 changes: 0 additions & 49 deletions example/lib/src/console.dart

This file was deleted.

2 changes: 1 addition & 1 deletion example/lib/src/mixed_fraction_analyzer.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:fraction/fraction.dart';
import 'package:fraction_example/src/analyzer.dart';

/// Tries to convert a [String] into a [MixedFraction]
/// Tries to convert a [String] into a [MixedFraction].
final class MixedFractionAnalyzer extends RationalAnalyzer {
/// Creates a [MixedFractionAnalyzer] object.
const MixedFractionAnalyzer({required String input}) : super(input);
Expand Down
42 changes: 0 additions & 42 deletions example/test/analyzer/fraction_analyzer_test.dart

This file was deleted.

43 changes: 0 additions & 43 deletions example/test/analyzer/mixed_fraction_analyzer_test.dart

This file was deleted.

12 changes: 2 additions & 10 deletions lib/src/types/mixed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import 'package:fraction/src/types/egyptian_converter.dart';
/// ```
///
/// Operators always return new objects. There are extension methods on [num]
/// and [String] that allow you to build [MixedFraction] objects "on the fly".
/// and [String] that allow you to build [MixedFraction] objects "on the fly".
/// For example:
///
/// ```dart
Expand Down Expand Up @@ -237,15 +237,7 @@ base class MixedFraction extends Rational {
}

@override
int get hashCode {
var result = 17;

result = result * 37 + whole.hashCode;
result = result * 37 + _numerator.hashCode;
result = result * 37 + _denominator.hashCode;

return result;
}
int get hashCode => Object.hash(whole, numerator, denominator);

@override
String toString() {
Expand Down
9 changes: 1 addition & 8 deletions lib/src/types/standard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,7 @@ base class Fraction extends Rational {
}

@override
int get hashCode {
var result = 17;

result = result * 37 + numerator.hashCode;
result = result * 37 + denominator.hashCode;

return result;
}
int get hashCode => Object.hash(numerator, denominator);

@override
String toString() {
Expand Down
8 changes: 6 additions & 2 deletions test/types/mixed_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,17 @@ void main() {
throwsA(isA<MixedFractionException>()),
);
expect(
() => MixedFraction.fromString('2 1/1'),
throwsA(isA<MixedFractionException>()),
() => MixedFraction.fromString('2 1/-1'),
throwsA(isA<FractionException>()),
);
expect(
() => MixedFraction.fromString('2 c/0'),
throwsA(isA<FractionException>()),
);
expect(
() => MixedFraction.fromString('1 2/0'),
throwsA(isA<FractionException>()),
);
},
);

Expand Down
2 changes: 1 addition & 1 deletion test/types/standard_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void main() {
throwsA(isA<FormatException>()),
);
expect(
() => Fraction.fromString('1/-3'),
() => Fraction.fromString('a/3'),
throwsA(isA<FractionException>()),
);
},
Expand Down

0 comments on commit e994c00

Please sign in to comment.