Skip to content

Commit

Permalink
Define iterate for AbstractString in stead of just String in the iter…
Browse files Browse the repository at this point in the history
…ate compatibility code. (#140)

* Define iterate for AbstractString in stead of just String. This allows AbstractString's to be used again, as was possible before
commit d061d91.

* Add parse.jl test using AbstractString.

* Avoid using Base.Test
  • Loading branch information
rbvermaa authored and omus committed Jun 13, 2018
1 parent be4ebb9 commit 187e9e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end

# https://github.com/JuliaLang/julia/pull/25261
if VERSION < v"0.7.0-DEV.5126"
iterate(str::String, i::Int) = next(str, i)
iterate(str::AbstractString, i::Int) = next(str, i)
end

function tryparsenext_fixedtz(str, i, len, min_width::Int=1, max_width::Int=0)
Expand Down
6 changes: 6 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import Compat.Dates: parse_components, default_format
ZonedDateTime(2000, tz"UTC"),
)
@test_throws ArgumentError parse(ZonedDateTime, "2016-04-11 08:00 EST", dateformat"yyyy-mm-dd HH:MM zzz")
# test AbstractString
@test isequal(
parse(ZonedDateTime, Test.GenericString("2018-01-01 00:00 UTC"), dateformat"yyyy-mm-dd HH:MM ZZZ"),
ZonedDateTime(2018, 1, 1, 0, tz"UTC"),
)

end

@testset "tryparse" begin
Expand Down

0 comments on commit 187e9e0

Please sign in to comment.