From ba31505777a0be3bdd5a7d4465b320fa81612a2f Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Thu, 27 Oct 2022 17:13:05 -0400 Subject: [PATCH] fixup --- base/iterators.jl | 2 +- test/iterators.jl | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/base/iterators.jl b/base/iterators.jl index a55aae5d4e7f82..0075ce93ab9d64 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -946,7 +946,7 @@ true ``` """ cycle(xs) = Cycle(xs) -cycle(xs, n::Int) = flatten(repeated(xs, n)) +cycle(xs, n::Integer) = flatten(repeated(xs, n)) eltype(::Type{Cycle{I}}) where {I} = eltype(I) IteratorEltype(::Type{Cycle{I}}) where {I} = IteratorEltype(I) diff --git a/test/iterators.jl b/test/iterators.jl index 89ec214bda8ace..6d0cbde420bb4c 100644 --- a/test/iterators.jl +++ b/test/iterators.jl @@ -251,8 +251,13 @@ let i = 0 end @testset "cycle(iter, n)" begin - @test cycle(0:3, 2) == [0, 1, 2, 3, 0, 1, 2, 3] + @test collect(cycle(0:3, 2)) == [0, 1, 2, 3, 0, 1, 2, 3] + @test collect(cycle(Iterators.filter(iseven, 1:4), 2)) == [2, 4, 2, 4] + @test collect(take(cycle(countfrom(11), 3), 4)) == 11:14 + @test isempty(cycle(1:0)) == isempty(cycle(1:0, 3)) == true + @test isempty(cycle(1:5, 0)) + @test isempty(cycle(Iterators.filter(iseven, 1:4), 0)) @test eltype(cycle(0:3, 2)) === Int @test Base.IteratorEltype(cycle(0:3, 2)) == Base.HasEltype()