Skip to content

Commit 336b7b5

Browse files
authored
fix deprecations of foldl and mapfoldl (#49)
1 parent 3cd196c commit 336b7b5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/stream.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,17 @@ end
135135
# Check that mode is valid.
136136
macro checkmode(validmodes)
137137
mode = esc(:mode)
138-
quote
139-
if !$(foldr((x, y) -> :($(mode) == $(QuoteNode(x)) || $(y)), false, eval(validmodes)))
140-
throw(ArgumentError(string("invalid mode :", $(mode))))
138+
if VERSION v"0.7.0-beta.210"
139+
quote
140+
if !$(foldr((x, y) -> :($(mode) == $(QuoteNode(x)) || $(y)), eval(validmodes), init=false))
141+
throw(ArgumentError(string("invalid mode :", $(mode))))
142+
end
143+
end
144+
else
145+
quote
146+
if !$(foldr((x, y) -> :($(mode) == $(QuoteNode(x)) || $(y)), false, eval(validmodes)))
147+
throw(ArgumentError(string("invalid mode :", $(mode))))
148+
end
141149
end
142150
end
143151
end

src/testtools.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function test_chunked_read(Encoder, Decoder)
8383
initialize(encoder)
8484
for _ in 1:500
8585
chunks = [rand(alpha, rand(0:100)) for _ in 1:rand(1:100)]
86-
data = mapfoldl(x->transcode(encoder, x), vcat, UInt8[], chunks)
86+
if VERSION v"0.7.0-beta.210"
87+
data = mapfoldl(x->transcode(encoder, x), vcat, chunks, init=UInt8[])
88+
else
89+
data = mapfoldl(x->transcode(encoder, x), vcat, UInt8[], chunks)
90+
end
8791
buffer = NoopStream(IOBuffer(data))
8892
ok = true
8993
local stream

0 commit comments

Comments
 (0)