Skip to content

Commit

Permalink
made iset constructor private
Browse files Browse the repository at this point in the history
  • Loading branch information
LowLevelSubmarine committed Mar 27, 2024
1 parent b5f63d3 commit 6c98563
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/src/iset/iset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ISetEmpty<T> // ignore: must_be_immutable
/// IMPORTANT: You must always use the `const` keyword.
/// It's always wrong to use an `ISetEmpty()` which is not constant.
@literal
const ISetEmpty([this.config = const ConfigSet()])
const ISetEmpty._([this.config = const ConfigSet()])
: super._gen();

@override
Expand Down Expand Up @@ -270,7 +270,7 @@ abstract class ISet<T> // ignore: must_be_immutable
/// Create an empty [ISet].
/// Use it with const: `const ISet.empty()` (It's always an [ISetEmpty]).
@literal
const factory ISet.empty() = ISetEmpty<T>;
const factory ISet.empty() = ISetEmpty<T>._;

const ISet._gen();

Expand Down
22 changes: 10 additions & 12 deletions test/iset/iset_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 ISetEmpty(), isA<ISetEmpty>());
expect(const ISetEmpty(), isA<ISetEmpty>());
expect(const ISetEmpty<String>(), isA<ISetEmpty<String>>());
expect(const ISetEmpty<int>(), isA<ISetEmpty<int>>());

expect(const ISetEmpty(), isA<ISet>());
expect(const ISetEmpty(), isA<ISet>());
expect(const ISetEmpty<String>(), isA<ISet<String>>());
expect(const ISetEmpty<int>(), isA<ISet<int>>());
expect(const ISet.empty(), isA<ISetEmpty>());
expect(const ISet.empty(), isA<ISetEmpty>());
expect(const ISet<String>.empty(), isA<ISetEmpty<String>>());
expect(const ISet<int>.empty(), isA<ISetEmpty<int>>());

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

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

test("Make sure the internal set is Set<int>, and not Set<Never>", () {
const s1 = ISetEmpty<int>();
const s1 = ISet<int>.empty();
expect(s1.runtimeType.toString(), 'ISetEmpty<int>');

const s2 = ISetConst<int>({1, 2, 3});
Expand All @@ -60,7 +60,6 @@ void main() {
expect(ISet().equalItems(const ISet.empty()), isTrue);
expect(const ISetConst({}).equalItems(const ISet.empty()), isTrue);
expect(const ISet.empty().equalItems(const ISet.empty()), isTrue);
expect(const ISet.empty().equalItems(const ISetEmpty()), isTrue);


// equalItemsAndConfig
Expand All @@ -70,7 +69,6 @@ void main() {
expect(ISet().equalItemsAndConfig(const ISet.empty()), isTrue);
expect(const ISetConst({}).equalItemsAndConfig(const ISet.empty()), isTrue);
expect(const ISet.empty().equalItemsAndConfig(const ISet.empty()), isTrue);
expect(const ISet.empty().equalItemsAndConfig(const ISetEmpty()), isTrue);
});

test("isEmpty | isNotEmpty", () {
Expand Down

0 comments on commit 6c98563

Please sign in to comment.