LCOV - code coverage report

Current view
top level - src/converters - num_converter.dart
Test
lcov.info
Date
2024-11-13
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines141593.3%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'converter.dart';
2
3final class NumConverter extends Converter {
411 const NumConverter();
5
6 static const instance = NumConverter();
7
81 @override
93 Cast<T> value<T>() => _numCastors[T] as Cast<T>? ?? Converter.identity<T>;
10
112 static int _toInt(dynamic x) {
123 if (x is int && x.isFinite) return x;
132 final y = (x as num).toDouble();
142 if (!y.isFinite) return double.nan as int; // intended type error
153 final z = y.toInt(), d = y - z;
162 if (d != 0) return double.nan as int; // intended type error
170 return z;
181 }
19
203 static double _toDbl(dynamic x) => (x as num).toDouble();
21
224 static final Map<Type, Cast> _numCastors = {
231 int: _toInt,
241 double: _toDbl,
25 };
26}
Choose Features