Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/comparison.jl
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,13 @@ function Base.IteratorSize(::Type{<:ExponentsIterator{M,Int}}) where {M}
return Base.HasLength()
end

function Base.:(==)(a::ExponentsIterator, b::ExponentsIterator)
return typeof(a.object) == typeof(b.object) &&
length(a.object) == length(b.object) &&
a.mindegree == b.mindegree &&
a.maxdegree == b.maxdegree
end

function _length(it::ExponentsIterator, maxdegree)
if maxdegree < it.mindegree
return 0
Expand Down
9 changes: 9 additions & 0 deletions test/comparison.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ function _test(nvars::Int, M; kws...)
return
end

function test_equal()
exp = ExponentsIterator{LexOrder}([0])
@test exp == ExponentsIterator{LexOrder}([0])
@test exp != ExponentsIterator{LexOrder}((0,))
@test exp != ExponentsIterator{LexOrder}([0, 0])
@test exp != ExponentsIterator{LexOrder}([0], mindegree = 1)
@test exp != ExponentsIterator{LexOrder}([0], maxdegree = 2)
end

function test_errors()
err = ArgumentError(
"The `mindegree` of `ExponentsIterator` cannot be negative.",
Expand Down