Skip to content

Commit

Permalink
few more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abraunst committed Apr 12, 2024
1 parent c51cf37 commit 884c0b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/accumulator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ Base.getindex(a::Accumulator, i) = first(a.sums)[i]

Base.sum(a::Accumulator{T,+,zero}) where T = only(last(a.sums))

function Base.reduce(op, a::Accumulator{T,OP,init}) where {T,OP,init}
@assert op == OP
only(last(a.sums))
end

Base.reduce(a::Accumulator{T,op,init}) where {T,op,init} = only(last(a.sums))

Base.isempty(a::Accumulator) = isempty(first(a.sums))
Expand Down
5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ v = rand(0:200, 20)
a = Accumulator(v)
c = cumsum(a)

@testset "Accumulator setindex!" begin
@testset "Accumulator" begin
@test a == v
@test a == Accumulator(v)
@test Accumulator(v) == a
@test sum(a) == sum(v)
@test a.sums == Accumulator(v).sums
a[3] = v[3] = 70
Expand Down

0 comments on commit 884c0b4

Please sign in to comment.