Skip to content

Commit d66eef2

Browse files
committed
Define take!(t::Task) = consume(t)
1 parent 40bc120 commit d66eef2

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

src/Compat.jl

+3
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ if VERSION < v"0.5.0-dev+961"
194194
Task(_it)
195195
end
196196
end
197+
if VERSION < v"0.6.0-dev.2043"
198+
Base.take!(t::Task) = consume(t)
199+
end
197200

198201
function rewrite_show(ex)
199202
if isexpr(ex, :call)

test/runtests.jl

+19-19
Original file line numberDiff line numberDiff line change
@@ -983,29 +983,29 @@ cd(dirwalk) do
983983
follow_symlink_vec = has_symlinks ? [true, false] : [false]
984984
has_symlinks && symlink(abspath("sub_dir2"), joinpath("sub_dir1", "link"))
985985
for follow_symlinks in follow_symlink_vec
986-
task = walkdir(".", follow_symlinks=follow_symlinks)
987-
root, dirs, files = consume(task)
986+
chnl = walkdir(".", follow_symlinks=follow_symlinks)
987+
root, dirs, files = take!(chnl)
988988
@test root == "."
989989
@test dirs == ["sub_dir1", "sub_dir2"]
990990
@test files == ["file1", "file2"]
991991

992-
root, dirs, files = consume(task)
992+
root, dirs, files = take!(chnl)
993993
@test root == joinpath(".", "sub_dir1")
994994
@test dirs == (has_symlinks ? ["link", "subsub_dir1", "subsub_dir2"] : ["subsub_dir1", "subsub_dir2"])
995995
@test files == ["file1", "file2"]
996996

997-
root, dirs, files = consume(task)
997+
root, dirs, files = take!(chnl)
998998
if follow_symlinks
999999
@test root == joinpath(".", "sub_dir1", "link")
10001000
@test dirs == []
10011001
@test files == ["file_dir2"]
1002-
root, dirs, files = consume(task)
1002+
root, dirs, files = take!(chnl)
10031003
end
10041004
for i=1:2
10051005
@test root == joinpath(".", "sub_dir1", "subsub_dir$i")
10061006
@test dirs == []
10071007
@test files == []
1008-
root, dirs, files = consume(task)
1008+
root, dirs, files = take!(chnl)
10091009
end
10101010

10111011
@test root == joinpath(".", "sub_dir2")
@@ -1014,51 +1014,51 @@ cd(dirwalk) do
10141014
end
10151015

10161016
for follow_symlinks in follow_symlink_vec
1017-
task = walkdir(".", follow_symlinks=follow_symlinks, topdown=false)
1018-
root, dirs, files = consume(task)
1017+
chnl = walkdir(".", follow_symlinks=follow_symlinks, topdown=false)
1018+
root, dirs, files = take!(chnl)
10191019
if follow_symlinks
10201020
@test root == joinpath(".", "sub_dir1", "link")
10211021
@test dirs == []
10221022
@test files == ["file_dir2"]
1023-
root, dirs, files = consume(task)
1023+
root, dirs, files = take!(chnl)
10241024
end
10251025
for i=1:2
10261026
@test root == joinpath(".", "sub_dir1", "subsub_dir$i")
10271027
@test dirs == []
10281028
@test files == []
1029-
root, dirs, files = consume(task)
1029+
root, dirs, files = take!(chnl)
10301030
end
10311031
@test root == joinpath(".", "sub_dir1")
10321032
@test dirs == (has_symlinks ? ["link", "subsub_dir1", "subsub_dir2"] : ["subsub_dir1", "subsub_dir2"])
10331033
@test files == ["file1", "file2"]
10341034

1035-
root, dirs, files = consume(task)
1035+
root, dirs, files = take!(chnl)
10361036
@test root == joinpath(".", "sub_dir2")
10371037
@test dirs == []
10381038
@test files == ["file_dir2"]
10391039

1040-
root, dirs, files = consume(task)
1040+
root, dirs, files = take!(chnl)
10411041
@test root == "."
10421042
@test dirs == ["sub_dir1", "sub_dir2"]
10431043
@test files == ["file1", "file2"]
10441044
end
10451045
#test of error handling
1046-
task_error = walkdir(".")
1047-
task_noerror = walkdir(".", onerror=x->x)
1048-
root, dirs, files = consume(task_error)
1046+
chnl_error = walkdir(".")
1047+
chnl_noerror = walkdir(".", onerror=x->x)
1048+
root, dirs, files = take!(chnl_error)
10491049
@test root == "."
10501050
@test dirs == ["sub_dir1", "sub_dir2"]
10511051
@test files == ["file1", "file2"]
10521052

10531053
rm(joinpath("sub_dir1"), recursive=true)
1054-
@test_throws SystemError consume(task_error) # throws an error because sub_dir1 do not exist
1054+
@test_throws SystemError take!(chnl_error) # throws an error because sub_dir1 do not exist
10551055

1056-
root, dirs, files = consume(task_noerror)
1056+
root, dirs, files = take!(chnl_noerror)
10571057
@test root == "."
10581058
@test dirs == ["sub_dir1", "sub_dir2"]
10591059
@test files == ["file1", "file2"]
10601060

1061-
root, dirs, files = consume(task_noerror) # skips sub_dir1 as it no longer exist
1061+
root, dirs, files = take!(chnl_noerror) # skips sub_dir1 as it no longer exist
10621062
@test root == joinpath(".", "sub_dir2")
10631063
@test dirs == []
10641064
@test files == ["file_dir2"]
@@ -1192,7 +1192,7 @@ let x = rand(3), y = rand(3)
11921192
@test @compat(sin.(cos.(x))) == map(x -> sin(cos(x)), x)
11931193
@test @compat(atan2.(sin.(y),x)) == broadcast(atan2,map(sin,y),x)
11941194
end
1195-
let x0 = Array(Float64), v, v0
1195+
let x0 = Array{Float64}(), v, v0
11961196
x0[1] = rand()
11971197
v0 = @compat sin.(x0)
11981198
@test isa(v0, Array{Float64,0})

0 commit comments

Comments
 (0)