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

albertms10 / music_notes / 16737193352

05 Aug 2025 12:16AM UTC coverage: 99.551% (-0.4%) from 100.0%
16737193352

Pull #608

github

web-flow
Merge a913ad009 into 0fed00049
Pull Request #608: refactor: ♻️ rename formatters to `*Notation`

274 of 280 new or added lines in 17 files covered. (97.86%)

1 existing line in 1 file now uncovered.

1553 of 1560 relevant lines covered (99.55%)

2.04 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();
16✔
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 interface 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 interface 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('End of parser chain: 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