Skip to content

Commit

Permalink
made imap constructor private
Browse files Browse the repository at this point in the history
  • Loading branch information
LowLevelSubmarine committed Mar 27, 2024
1 parent 6c98563 commit 6a1db89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/src/imap/imap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class IMapEmpty<K, V> // 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
Expand Down Expand Up @@ -255,7 +255,7 @@ abstract class IMap<K, V> // 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<K, V>;
const factory IMap.empty() = IMapEmpty<K, V>._;

const IMap._gen();

Expand Down
22 changes: 10 additions & 12 deletions test/imap/imap_empty_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ void main() {
});

test("Runtime Type", () {
expect(const IMapEmpty(), isA<IMapEmpty>());
expect(const IMapEmpty(), isA<IMapEmpty>());
expect(const IMapEmpty<String, String>(), isA<IMapEmpty<String, String>>());
expect(const IMapEmpty<int, String>(), isA<IMapEmpty<int, String>>());

expect(const IMapEmpty(), isA<IMap>());
expect(const IMapEmpty(), isA<IMap>());
expect(const IMapEmpty<String, String>(), isA<IMap<String, String>>());
expect(const IMapEmpty<int, String>(), isA<IMap<int, String>>());
expect(const IMap.empty(), isA<IMapEmpty>());
expect(const IMap.empty(), isA<IMapEmpty>());
expect(const IMap<String, String>.empty(), isA<IMapEmpty<String, String>>());
expect(const IMap<int, String>.empty(), isA<IMap<int, String>>());

expect(const IMap.empty(), isA<IMap>());
expect(const IMap.empty(), isA<IMap>());
expect(const IMap<String, String>.empty(), isA<IMap<String, String>>());
expect(const IMap<int, String>.empty(), isA<IMap<int, String>>());
});

test("Make sure the IMapEmpty can be modified and later iterated", () {
Expand All @@ -44,7 +44,7 @@ void main() {
});

test("Make sure the internal map is Map<int, String>, and not Map<Never>", () {
const m1 = IMapEmpty<String, int>();
const m1 = IMap<String, int>.empty();
expect(m1.runtimeType.toString(), 'IMapEmpty<String, int>');

const m2 = IMapConst<String, int>({'a': 1, 'b': 2, 'c': 3});
Expand All @@ -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
Expand All @@ -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", () {
Expand Down

0 comments on commit 6a1db89

Please sign in to comment.