From 05052a0e95c7fabb73251fbdb2959e321e79fae6 Mon Sep 17 00:00:00 2001 From: d-markey Date: Sat, 2 Nov 2024 16:01:31 +0000 Subject: [PATCH] Automated test coverage report --- coverage.json | 2 +- doc/coverage/html/index.html | 6 +- .../src/_impl/native/_platform.dart.gcov.html | 2 +- .../src/_impl/web/_platform.dart.gcov.html | 2 +- doc/coverage/html/src/index.html | 8 +- .../src/squadron_singleton.dart.gcov.html | 163 +++++++++++++++-- doc/coverage/xml/index.xml | 4 +- .../src/_impl/native/_platform.dart.gcov.xml | 4 +- .../xml/src/_impl/web/_platform.dart.gcov.xml | 4 +- doc/coverage/xml/src/index.xml | 6 +- .../xml/src/squadron_singleton.dart.gcov.xml | 173 +++++++++++++++++- 11 files changed, 335 insertions(+), 39 deletions(-) diff --git a/coverage.json b/coverage.json index a11b2bc9..9a1951a0 100644 --- a/coverage.json +++ b/coverage.json @@ -1 +1 @@ -{"linesValid":2377,"lineRate":87.4} \ No newline at end of file +{"linesValid":2392,"lineRate":87.5} \ No newline at end of file diff --git a/doc/coverage/html/index.html b/doc/coverage/html/index.html index 572a8c64..5efbd52e 100644 --- a/doc/coverage/html/index.html +++ b/doc/coverage/html/index.html @@ -37,7 +37,7 @@

LCOV - code coverage report

- Lines2078237787.4% + Lines2092239287.5% Functions00- @@ -61,8 +61,8 @@

LCOV - code coverage report

src - 77.8% - 77.8%28/36-0/0-0/0 + 82.4% + 82.4%42/51-0/0-0/0 src/_impl/native diff --git a/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html b/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html index c532ef50..46b80054 100644 --- a/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html +++ b/doc/coverage/html/src/_impl/native/_platform.dart.gcov.html @@ -73,7 +73,7 @@

LCOV - code coverage report

4 - 58Converter getPlatformConverter() => DirectCastConverter.instance; + 59Converter getPlatformConverter() => DirectCastConverter.instance; 6 diff --git a/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html b/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html index d2efbcab..865605fa 100644 --- a/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html +++ b/doc/coverage/html/src/_impl/web/_platform.dart.gcov.html @@ -82,7 +82,7 @@

LCOV - code coverage report

7Converter getPlatformConverter() => (1.toDouble() is int) - 88 ? CastConverter.instance // JavaScript + 89 ? CastConverter.instance // JavaScript 9 : NumConverter.instance; // Web Assembly diff --git a/doc/coverage/html/src/index.html b/doc/coverage/html/src/index.html index bfa556e2..6e3be7a3 100644 --- a/doc/coverage/html/src/index.html +++ b/doc/coverage/html/src/index.html @@ -39,7 +39,7 @@

LCOV - code coverage report

- Lines283677.8% + Lines425182.4% Functions00- @@ -95,11 +95,11 @@

LCOV - code coverage report

squadron_singleton.dart - 100.0% - 100.0%3/3-0/0-0/0 + 94.4% + 94.4%17/18-0/0-0/0 - <unnamed>100.0%3/3-0/0-0/0 + <unnamed>94.4%17/18-0/0-0/0 typedefs.dart diff --git a/doc/coverage/html/src/squadron_singleton.dart.gcov.html b/doc/coverage/html/src/squadron_singleton.dart.gcov.html index a32c7615..09bc934f 100644 --- a/doc/coverage/html/src/squadron_singleton.dart.gcov.html +++ b/doc/coverage/html/src/squadron_singleton.dart.gcov.html @@ -40,7 +40,7 @@

LCOV - code coverage report

- Lines33100.0% + Lines171894.4% Functions00- @@ -73,25 +73,166 @@

LCOV - code coverage report

4 if (dart.library.js_interop) '_impl/web/_platform.dart' as impl; - 5 + 5import 'converters/converter.dart'; - 6class Squadron { + 6 - - 732 static final converter = impl.getPlatformConverter(); + + 7class Squadron { - - 88 static final platformType = impl.getPlatformType(); + + 80 Squadron._(); 9 - - 1012 static Uri uri(String url) => impl.mapUrl(url); + + 10 /// Gets the current platform type. - - 11} + + 118 static final platformType = impl.getPlatformType(); + + + 12 + + + 13 /// Parse [url] and returns the corresponding [Uri]. + + + 14 /// + + + 15 /// On Web platforms, a leading '~' character will be replaced with the + + + 16 /// current page's root URL. E.g. '~/workers' from '/path/to/index.html' + + + 17 /// will return '/path/to/workers'. + + + 1812 static Uri uri(String url) => impl.mapUrl(url); + + + 19 + + + 2036 static final _platformConverter = impl.getPlatformConverter(); + + + 2136 static Converter _converter = _platformConverter; + + + 22 + + + 23 /// Gets the current converter. + + + 2427 static Converter get converter => _converter; + + + 25 + + + 26 /// Sets the current converter. If [value] is `null`, the default converter + + + 27 /// will be restored. If the converter was updated, handlers registered with + + + 28 /// [onConverterChanged] will be notified of the change. + + + 292 static set converter(Converter? value) { + + + 302 value ??= _platformConverter; + + + 313 if (_converter != value) { + + + 32 _converter = value; + + + 334 for (var handler in _converterChangeHandlers.values) { + + + 34 try { + + + 352 handler(); + + + 36 } catch (_) { + + + 37 // ignore + + + 38 } + + + 39 } + + + 40 } + + + 411 } + + + 42 + + + 433 static final _converterChangeHandlers = <Object, void Function()>{}; + + + 44 + + + 45 /// Registers a callback that will be called whenever `converter` is changed. + + + 46 /// Returns an object that can be used to unregister the callback by passing + + + 47 /// it to [unregisterConverterChanged]. + + + 481 static Object onConverterChanged(void Function() handler) { + + + 491 final key = Object(); + + + 503 _converterChangeHandlers[key] = handler; + + + 51 return key; + + + 52 } + + + 53 + + + 54 /// Unregisters a callback that was registered with [onConverterChanged]. + + + 551 static void unregisterConverterChanged(Object key) { + + + 563 _converterChangeHandlers.remove(key); + + + 57 } + + + 58} diff --git a/doc/coverage/xml/index.xml b/doc/coverage/xml/index.xml index fdbde8e6..f8dfdda6 100644 --- a/doc/coverage/xml/index.xml +++ b/doc/coverage/xml/index.xml @@ -1,8 +1,8 @@ - + - + diff --git a/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml b/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml index 3e3e16cb..f14852cc 100644 --- a/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/native/_platform.dart.gcov.xml @@ -13,9 +13,9 @@ - + Converter getPlatformConverter() => DirectCastConverter.instance; - + diff --git a/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml b/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml index df3237e1..e20798cf 100644 --- a/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml +++ b/doc/coverage/xml/src/_impl/web/_platform.dart.gcov.xml @@ -22,9 +22,9 @@ Converter getPlatformConverter() => (1.toDouble() is int) - + ? CastConverter.instance // JavaScript - + : NumConverter.instance; // Web Assembly diff --git a/doc/coverage/xml/src/index.xml b/doc/coverage/xml/src/index.xml index 37045240..f26add7f 100644 --- a/doc/coverage/xml/src/index.xml +++ b/doc/coverage/xml/src/index.xml @@ -1,5 +1,5 @@ - + @@ -16,8 +16,8 @@ - - + + diff --git a/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml b/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml index 3d7d990c..4e7d2219 100644 --- a/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml +++ b/doc/coverage/xml/src/squadron_singleton.dart.gcov.xml @@ -1,5 +1,5 @@ - + import '_impl/xplat/_platform.dart' @@ -14,27 +14,182 @@ if (dart.library.js_interop) '_impl/web/_platform.dart' as impl; - + import 'converters/converter.dart'; + + + class Squadron { - - static final converter = impl.getPlatformConverter(); - + + Squadron._(); + + + - + + /// Gets the current platform type. + + static final platformType = impl.getPlatformType(); - + - + + /// Parse [url] and returns the corresponding [Uri]. + + + /// + + + /// On Web platforms, a leading '~' character will be replaced with the + + + /// current page's root URL. E.g. '~/workers' from '/path/to/index.html' + + + /// will return '/path/to/workers'. + + static Uri uri(String url) => impl.mapUrl(url); - + + + + + static final _platformConverter = impl.getPlatformConverter(); + + + + static Converter _converter = _platformConverter; + + + + + + + /// Gets the current converter. + + + static Converter get converter => _converter; + + + + + + + /// Sets the current converter. If [value] is `null`, the default converter + + + /// will be restored. If the converter was updated, handlers registered with + + + /// [onConverterChanged] will be notified of the change. + + + static set converter(Converter? value) { + + + + value ??= _platformConverter; + + + + if (_converter != value) { + + + + _converter = value; + + + for (var handler in _converterChangeHandlers.values) { + + + + try { + + + handler(); + + + + } catch (_) { + + + // ignore + + + } + + + } + + + } + + + } + + + + + + + static final _converterChangeHandlers = <Object, void Function()>{}; + + + + + + + /// Registers a callback that will be called whenever `converter` is changed. + + + /// Returns an object that can be used to unregister the callback by passing + + + /// it to [unregisterConverterChanged]. + + + static Object onConverterChanged(void Function() handler) { + + + + final key = Object(); + + + + _converterChangeHandlers[key] = handler; + + + + return key; + + + } + + + + + + /// Unregisters a callback that was registered with [onConverterChanged]. + + + static void unregisterConverterChanged(Object key) { + + + + _converterChangeHandlers.remove(key); + + + + } + + }