From 6a1db898b47ecbfac69384f2233c0cad51e845c4 Mon Sep 17 00:00:00 2001 From: LowLevelSubmarine Date: Wed, 27 Mar 2024 19:08:38 +0100 Subject: [PATCH] made imap constructor private --- lib/src/imap/imap.dart | 4 ++-- test/imap/imap_empty_test.dart | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/src/imap/imap.dart b/lib/src/imap/imap.dart index 718c46d..3502424 100644 --- a/lib/src/imap/imap.dart +++ b/lib/src/imap/imap.dart @@ -24,7 +24,7 @@ class IMapEmpty // ignore: must_be_immutable /// IMPORTANT: You must always use the `const` keyword. /// It's always wrong to use an `IMapEmpty()` which is not constant. @literal - const IMapEmpty([this.config = const ConfigMap()]) + const IMapEmpty._([this.config = const ConfigMap()]) : super._gen(); @override @@ -255,7 +255,7 @@ abstract class IMap // ignore: must_be_immutable /// Create an empty [IMap]. /// Use it with const: `const IMap.empty()` (It's always an [IMapEmpty]). @literal - const factory IMap.empty() = IMapEmpty; + const factory IMap.empty() = IMapEmpty._; const IMap._gen(); diff --git a/test/imap/imap_empty_test.dart b/test/imap/imap_empty_test.dart index a5f5e04..9223bd4 100644 --- a/test/imap/imap_empty_test.dart +++ b/test/imap/imap_empty_test.dart @@ -11,15 +11,15 @@ void main() { }); test("Runtime Type", () { - expect(const IMapEmpty(), isA()); - expect(const IMapEmpty(), isA()); - expect(const IMapEmpty(), isA>()); - expect(const IMapEmpty(), isA>()); - - expect(const IMapEmpty(), isA()); - expect(const IMapEmpty(), isA()); - expect(const IMapEmpty(), isA>()); - expect(const IMapEmpty(), isA>()); + expect(const IMap.empty(), isA()); + expect(const IMap.empty(), isA()); + expect(const IMap.empty(), isA>()); + expect(const IMap.empty(), isA>()); + + expect(const IMap.empty(), isA()); + expect(const IMap.empty(), isA()); + expect(const IMap.empty(), isA>()); + expect(const IMap.empty(), isA>()); }); test("Make sure the IMapEmpty can be modified and later iterated", () { @@ -44,7 +44,7 @@ void main() { }); test("Make sure the internal map is Map, and not Map", () { - const m1 = IMapEmpty(); + const m1 = IMap.empty(); expect(m1.runtimeType.toString(), 'IMapEmpty'); const m2 = IMapConst({'a': 1, 'b': 2, 'c': 3}); @@ -69,7 +69,6 @@ void main() { expect(IMap().equalItems(const IMap.empty().entries), isTrue); expect(const IMapConst({}).equalItems(const IMap.empty().entries), isTrue); expect(const IMap.empty().equalItems(const IMap.empty().entries), isTrue); - expect(const IMap.empty().equalItems(const IMapEmpty().entries), isTrue); // equalItemsAndConfig @@ -79,7 +78,6 @@ void main() { expect(IMap().equalItemsAndConfig(const IMap.empty()), isTrue); expect(const IMapConst({}).equalItemsAndConfig(const IMap.empty()), isTrue); expect(const IMap.empty().equalItemsAndConfig(const IMap.empty()), isTrue); - expect(const IMap.empty().equalItemsAndConfig(const IMapEmpty()), isTrue); }); test("isEmpty | isNotEmpty", () {