• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

albertms10 / music_notes / 15889365663

25 Jun 2025 11:32PM UTC coverage: 97.841% (-2.2%) from 100.0%
15889365663

Pull #608

github

web-flow
Merge 542d1fa7c into 5122c56a3
Pull Request #608: refactor: ♻️ rename formatters to `*Notation`

152 of 181 new or added lines in 16 files covered. (83.98%)

3 existing lines in 1 file now uncovered.

1450 of 1482 relevant lines covered (97.84%)

2.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/src/notation_system.dart
1
// ignore_for_file: one_member_abstracts - Code reusability
2

3
/// An abstract representation of a notation system for parsing
4
/// and formatting [T].
5
///
6
/// The [format] and [parse] methods should be designed to be [inverses](https://en.wikipedia.org/wiki/Inverse_function)
7
/// of each other:
8
/// the output of [format] should be a valid argument for [parse], and
9
/// `parse(format(value))` should return a value equal to the original value.
10
abstract class NotationSystem<T> implements Formatter<T>, Parser<T> {
11
  /// Creates a new formatter.
12
  const NotationSystem();
15✔
13

14
  /// Formats this [T].
15
  ///
16
  /// The output of this method should be accepted by [parse] to reconstruct
17
  /// the original value.
18
  @override
19
  String format(T value);
20

21
  @override
1✔
22
  bool matches(String source) => true;
23

24
  /// Parses [source] as [T].
25
  ///
26
  /// The input [source] should typically be produced by [format], ensuring
27
  /// that `parse(format(value)) == value`.
28
  ///
29
  /// If the [source] string does not contain a valid [T], a [FormatException]
30
  /// should be thrown.
31
  @override
32
  T parse(String source);
33
}
34

35
/// An abstract representation of a formatter for [T].
36
abstract class Formatter<T> {
37
  /// Formats this [T].
38
  String format(T value);
39
}
40

41
/// An abstract representation of a parser for [T].
42
abstract class Parser<T> {
43
  /// Whether [source] can be parsed with [parse].
NEW
44
  bool matches(String source) => true;
×
45

46
  /// Parses [source] as [T].
47
  T parse(String source);
48
}
49

50
/// A [Parser] chain.
51
extension ParserChain<T> on List<Parser<T>> {
52
  /// Parses [source] from this chain of [Parser]s.
53
  T parse(String source) {
1✔
54
    for (final parser in this) {
2✔
55
      if (parser.matches(source)) return parser.parse(source);
2✔
56
    }
57
    throw FormatException('Invalid $T', source);
2✔
58
  }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc