LCOV - code coverage report

Current view
top level - src/converters - num_converter.dart
Test
lcov.info
Date
2025-03-26
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines1111100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import '../typedefs.dart';
2import 'converter.dart';
3
4final class NumConverter extends Converter {
513 const NumConverter();
6
7 static const instance = NumConverter();
8
91 @override
10 Cast<T> value<T extends Object>() {
111 if (T == int) return _toInt as Cast<T>;
121 if (T == double) return _toDbl as Cast<T>;
13 return Converter.identity<T>;
14 }
15
161 static int _toInt(dynamic x) {
17 x as num;
182 if (x is int && x.isFinite) return x;
191 double y = x.toDouble();
201 if (!y.isFinite) return double.nan as int; // intended type error
212 final z = y.toInt(), d = y - z;
221 if (d != 0) return double.nan as int; // intended type error
23 return z;
24 }
25
262 static double _toDbl(dynamic x) => (x as num).toDouble();
27}
Choose Features